Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions Rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,19 @@ pub struct FastNoiseLite {

impl Default for FastNoiseLite {
fn default() -> Self {
Self::new()
}
}

impl FastNoiseLite {
// =====================
// Constructor functions
// =====================

/// # Constructor
///
/// Create new FastNoise object with the default seed of `1337`.
pub const fn new() -> Self {
Self {
seed: 1337,
frequency: 0.01,
Expand All @@ -248,7 +261,7 @@ impl Default for FastNoiseLite {
weighted_strength: 0.,
ping_pong_strength: 2.,

/* private */ fractal_bounding: 1. / 1.75,
/* private */ fractal_bounding: 0.5714285714, // = 1.0 / 1.75

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change necessary? I think it might have been required in the past but now floating point math is allowed in const. I changed this locally and did a cargo check. Although I wonder if we'd need an MSRV declaration, which would make it a breaking change?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you're correct, certain float ops have since been stabilized in const. I would personally consider it something of a breaking change, so you'd have to decide how to handle that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just checked that the float ops do now work on stable. Are you concerned about the bump of the MSRV as a breaking change? If so we could explicitly mention the minimum rust version needed as part of the package description so people who are still on older rust version could just the previous version

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kyllingene any updates regarding this?


cellular_distance_function: CellularDistanceFunction::EuclideanSq,
cellular_return_type: CellularReturnType::Distance,
Expand All @@ -259,24 +272,11 @@ impl Default for FastNoiseLite {
domain_warp_amp: 1.,
}
}
}

impl FastNoiseLite {
// =====================
// Constructor functions
// =====================

/// # Constructor
///
/// Create new FastNoise object with the default seed of `1337`.
pub fn new() -> Self {
Self::default()
}

/// Create new FastNoise object with a specific seed.
pub fn with_seed(seed: i32) -> Self {
let mut fnl = Self::default();
fnl.set_seed(Some(seed));
pub const fn with_seed(seed: i32) -> Self {
let mut fnl = Self::new();
fnl.seed = seed;
fnl
}

Expand Down