diff options
author | stuebinm | 2021-05-08 18:38:37 +0200 |
---|---|---|
committer | stuebinm | 2021-05-08 18:38:37 +0200 |
commit | 3d4afe62809ad5263b303a29ec543e4c39310d97 (patch) | |
tree | 94c9ffdda05d88cfbd2608669b7165dddc8d8f4f | |
parent | e65c53a8e22e2edf209a31ad28ba67ac5d78bed7 (diff) |
inject_types -> with_builtin_typessubstitutions
at request of Nadrieril.
-rw-r--r-- | serde_dhall/src/options/de.rs | 6 | ||||
-rw-r--r-- | serde_dhall/tests/serde.rs | 20 |
2 files changed, 13 insertions, 13 deletions
diff --git a/serde_dhall/src/options/de.rs b/serde_dhall/src/options/de.rs index 4f7c346..3f0686d 100644 --- a/serde_dhall/src/options/de.rs +++ b/serde_dhall/src/options/de.rs @@ -258,14 +258,14 @@ impl<'a, A> Deserializer<'a, A> { /// let data = "Newtype.Bar"; /// /// let deserialized = serde_dhall::from_str(data) - /// .inject_types(substs) + /// .with_builtin_types(substs) /// .parse::<Newtype>() /// .unwrap(); /// /// assert_eq!(deserialized, Newtype::Bar); /// /// ``` - pub fn inject_types( + pub fn with_builtin_types( self, tys: impl IntoIterator<Item = (String, SimpleType)>, ) -> Self { @@ -285,7 +285,7 @@ impl<'a, A> Deserializer<'a, A> { } } - pub fn inject_single_type(self, name: String, ty: SimpleType) -> Self { + pub fn with_builtin_type(self, name: String, ty: SimpleType) -> Self { Deserializer { substitutions: self .substitutions diff --git a/serde_dhall/tests/serde.rs b/serde_dhall/tests/serde.rs index abf78e3..37fbc0f 100644 --- a/serde_dhall/tests/serde.rs +++ b/serde_dhall/tests/serde.rs @@ -151,7 +151,7 @@ mod serde { } #[test] - fn inject_single_type() { + fn with_builtin_type() { #[derive(Debug, Clone, Deserialize, Serialize, StaticType, Eq, PartialEq)] enum Foo { X(u64), @@ -159,7 +159,7 @@ mod serde { } assert_eq!(from_str("Foo.X 1") - .inject_single_type("Foo".to_string(), Foo::static_type()) + .with_builtin_type("Foo".to_string(), Foo::static_type()) .static_type_annotation() .parse::<Foo>() .unwrap(), @@ -180,8 +180,8 @@ mod serde { } assert_eq!(from_str("Foo.X Bar.A") - .inject_single_type("Bar".to_string(), Bar::static_type()) - .inject_single_type("Foo".to_string(), Foo::static_type()) + .with_builtin_type("Bar".to_string(), Bar::static_type()) + .with_builtin_type("Foo".to_string(), Foo::static_type()) .static_type_annotation() .parse::<Foo>() .unwrap(), @@ -192,8 +192,8 @@ mod serde { substs.insert("Foo".to_string(), Foo::static_type()); assert_eq!(from_str("Foo.X Bar.A") - .inject_types(substs.clone()) - .inject_single_type("Bar".to_string(), Bar::static_type()) + .with_builtin_types(substs.clone()) + .with_builtin_type("Bar".to_string(), Bar::static_type()) .static_type_annotation() .parse::<Foo>() .unwrap(), @@ -205,8 +205,8 @@ mod serde { substs.insert("Bar".to_string(), Foo::static_type()); assert_eq!(from_str("Foo.X Bar.A") - .inject_types(substs) - .inject_single_type("Bar".to_string(), Bar::static_type()) + .with_builtin_types(substs) + .with_builtin_type("Bar".to_string(), Bar::static_type()) .static_type_annotation() .parse::<Foo>() .unwrap(), @@ -217,7 +217,7 @@ mod serde { } #[test] - fn inject_types() { + fn with_builtin_types() { #[derive(Debug, Clone, Deserialize, Serialize, StaticType, Eq, PartialEq)] enum Foo { X(u64), @@ -228,7 +228,7 @@ mod serde { substs.insert("Foo".to_string(), Foo::static_type()); assert_eq!(from_str("Foo.X 1") - .inject_types(substs) + .with_builtin_types(substs) .static_type_annotation() .parse::<Foo>() .unwrap(), |