Skip to content

Commit 19ea8e4

Browse files
authored
Change from f32 to f64 for duration_seconds (#902)
Elsewhere in the OpenAPI spec this is (implicitly?) turned into a f64. Due to a long string of things I talk often about, this changes the represntation enough to change the value from 0.4 to 0.4000000059604645 Don't believe me? See for yourself! ```rust fn main() { let x: f64 = (0.4 as f32) as f64; eprintln!("{:?}", x) } ``` This, even more hilariously, shows up in the OpenAPI spec: ```sh $ curl https://api.zoo.dev/ \ | jq '.components.schemas.ModelingCmd.oneOf[] | select(.description | contains("Fade entity in or out.")).properties.duration_seconds' { "default": 0.4000000059604645, "description": "How many seconds the animation should take.", "format": "float", "type": "number" } ``` This changes the default to f64 which doesn't appear to break anything i've built locally -- although I haven't been able to pull this all the way through due to other upgrade-path issues. That being said this is a pretty easy one to fix (or revert) if it causes issues.
1 parent 6c4264e commit 19ea8e4

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

modeling-cmds-macros-impl/benches/my_benchmark.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn criterion_benchmark(c: &mut Criterion) {
2727
};
2828

2929
/// Mike says this usually looks nice.
30-
fn default_animation_seconds() -> f32 {
30+
fn default_animation_seconds() -> f64 {
3131
0.4
3232
}
3333

@@ -660,7 +660,7 @@ fn criterion_benchmark(c: &mut Criterion) {
660660
pub fade_in: bool,
661661
/// How many seconds the animation should take.
662662
#[serde(default = "default_animation_seconds")]
663-
pub duration_seconds: f32,
663+
pub duration_seconds: f64,
664664
}
665665

666666
/// Make a new plane

modeling-cmds/src/def_enum.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ define_modeling_cmd_enum! {
3737
};
3838

3939
/// Mike says this usually looks nice.
40-
fn default_animation_seconds() -> f32 {
40+
fn default_animation_seconds() -> f64 {
4141
0.4
4242
}
4343

@@ -980,7 +980,7 @@ define_modeling_cmd_enum! {
980980
pub fade_in: bool,
981981
/// How many seconds the animation should take.
982982
#[serde(default = "default_animation_seconds")]
983-
pub duration_seconds: f32,
983+
pub duration_seconds: f64,
984984
}
985985

986986
/// Make a new plane

0 commit comments

Comments
 (0)