mirror of
https://github.com/tiffany352/rink-rs
synced 2024-11-10 13:44:15 +00:00
Serialize Dim as a string to fix json failure
This commit is contained in:
parent
26a8231fa3
commit
97182a11f7
1 changed files with 11 additions and 1 deletions
|
@ -200,10 +200,20 @@ impl<'a> Neg for &'a Num {
|
|||
pub type Unit = BTreeMap<Dim, i64>;
|
||||
|
||||
/// A newtype for a string dimension ID, so that we can implement traits for it.
|
||||
#[cfg_attr(feature = "nightly", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "nightly", derive(Deserialize))]
|
||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||
pub struct Dim(pub Rc<String>);
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
impl ::serde::ser::Serialize for Dim {
|
||||
fn serialize<S>(
|
||||
&self, serializer: &mut S
|
||||
) -> Result<(), S::Error>
|
||||
where S: ::serde::ser::Serializer {
|
||||
serializer.serialize_str(&**self.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// The basic representation of a number with a unit.
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub struct Number(pub Num, pub Unit);
|
||||
|
|
Loading…
Reference in a new issue