-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added custom smoothness for bool support
- Loading branch information
Showing
4 changed files
with
44 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use serde::Serialize; | ||
|
||
pub enum Smoothness { | ||
Single(f64), | ||
Boolean(bool), | ||
} | ||
|
||
impl Serialize for Smoothness { | ||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | ||
where | ||
S: serde::Serializer, | ||
{ | ||
match self { | ||
Smoothness::Single(smoothness) => serializer.serialize_f64(*smoothness), | ||
Smoothness::Boolean(smoothness) => serializer.serialize_bool(*smoothness), | ||
} | ||
} | ||
} | ||
|
||
impl From<f64> for Smoothness { | ||
fn from(smoothness: f64) -> Self { | ||
Smoothness::Single(smoothness) | ||
} | ||
} | ||
|
||
impl From<i64> for Smoothness { | ||
fn from(smoothness: i64) -> Self { | ||
Smoothness::Single(smoothness as f64) | ||
} | ||
} | ||
|
||
impl From<bool> for Smoothness { | ||
fn from(smoothness: bool) -> Self { | ||
Smoothness::Boolean(smoothness) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters