Skip to content
Open
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions source/postcard-schema-ng/src/impls/builtins_alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ impl<K: Schema> Schema for alloc::collections::BTreeSet<K> {
const SCHEMA: &'static DataModelType = &DataModelType::Seq(K::SCHEMA);
}

#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "use-std"))))]
impl<T: Schema> Schema for alloc::collections::VecDeque<T> {
const SCHEMA: &'static DataModelType = &DataModelType::Seq(T::SCHEMA);
}

#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "use-std"))))]
impl<T: Schema> Schema for alloc::boxed::Box<T> {
const SCHEMA: &'static DataModelType = T::SCHEMA;
Expand All @@ -36,3 +41,8 @@ impl<T: Schema> Schema for alloc::boxed::Box<T> {
impl<T: ?Sized + Schema + alloc::borrow::ToOwned> Schema for alloc::borrow::Cow<'_, T> {
const SCHEMA: &'static DataModelType = T::SCHEMA;
}

#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "use-std"))))]
impl<T: Schema> Schema for alloc::rc::Rc<T> {
const SCHEMA: &'static DataModelType = T::SCHEMA;
}
15 changes: 15 additions & 0 deletions source/postcard-schema-ng/src/impls/builtins_std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ impl<K: Schema> Schema for std::collections::BTreeSet<K> {
const SCHEMA: &'static DataModelType = &DataModelType::Seq(K::SCHEMA);
}

#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "use-std"))))]
impl<T: Schema> Schema for std::collections::VecDeque<T> {
const SCHEMA: &'static DataModelType = &DataModelType::Seq(T::SCHEMA);
}

#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "use-std"))))]
impl<T: Schema> Schema for std::boxed::Box<T> {
const SCHEMA: &'static DataModelType = T::SCHEMA;
Expand All @@ -52,3 +57,13 @@ impl<T: Schema> Schema for std::boxed::Box<T> {
impl<T: ?Sized + Schema + std::borrow::ToOwned> Schema for std::borrow::Cow<'_, T> {
const SCHEMA: &'static DataModelType = T::SCHEMA;
}

#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "use-std"))))]
impl<T: Schema> Schema for std::rc::Rc<T> {
const SCHEMA: &'static DataModelType = T::SCHEMA;
}

#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "use-std"))))]
impl<T: Schema> Schema for std::sync::Arc<T> {
const SCHEMA: &'static DataModelType = T::SCHEMA;
}
3 changes: 3 additions & 0 deletions source/postcard-schema-ng/tests/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ fn smoke() {
(dewit::<Option<Classic>>, "Option<Classic>"),
(dewit::<Option<ClassicGen<i32>>>, "Option<ClassicGen>"),
(dewit::<PathBuf>, "String"),
(dewit::<std::collections::VecDeque<u32>>, "[u32]"),
(dewit::<std::rc::Rc<u32>>, "u32"),
(dewit::<std::sync::Arc<u32>>, "u32"),
];
for (f, s) in tests {
assert_eq!(f().as_str(), *s);
Expand Down
16 changes: 16 additions & 0 deletions source/postcard-schema/src/impls/builtins_alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ impl<K: Schema> Schema for alloc::collections::BTreeSet<K> {
};
}

#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "use-std"))))]
impl<T: Schema> Schema for alloc::collections::VecDeque<T> {
const SCHEMA: &'static NamedType = &NamedType {
name: "VecDeque<T>",
ty: &DataModelType::Seq(T::SCHEMA),
};
}

#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "use-std"))))]
impl<T: Schema> Schema for alloc::boxed::Box<T> {
const SCHEMA: &'static NamedType = &NamedType {
Expand All @@ -57,3 +65,11 @@ impl<T: ?Sized + Schema + alloc::borrow::ToOwned> Schema for alloc::borrow::Cow<
ty: T::SCHEMA.ty,
};
}

#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "use-std"))))]
impl<T: Schema> Schema for alloc::rc::Rc<T> {
const SCHEMA: &'static NamedType = &NamedType {
name: "Rc<T>",
ty: T::SCHEMA.ty,
};
}
24 changes: 24 additions & 0 deletions source/postcard-schema/src/impls/builtins_std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ impl<K: Schema> Schema for std::collections::BTreeSet<K> {
};
}

#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "use-std"))))]
impl<T: Schema> Schema for std::collections::VecDeque<T> {
const SCHEMA: &'static NamedType = &NamedType {
name: "VecDeque<T>",
ty: &DataModelType::Seq(T::SCHEMA),
};
}

#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "use-std"))))]
impl<T: Schema> Schema for std::boxed::Box<T> {
const SCHEMA: &'static NamedType = T::SCHEMA;
Expand All @@ -76,3 +84,19 @@ impl<T: Schema> Schema for std::boxed::Box<T> {
impl<T: ?Sized + Schema + std::borrow::ToOwned> Schema for std::borrow::Cow<'_, T> {
const SCHEMA: &'static NamedType = T::SCHEMA;
}

#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "use-std"))))]
impl<T: Schema> Schema for std::rc::Rc<T> {
const SCHEMA: &'static NamedType = &NamedType {
name: "Rc<T>",
ty: T::SCHEMA.ty,
};
}

#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "use-std"))))]
impl<T: Schema> Schema for std::sync::Arc<T> {
const SCHEMA: &'static NamedType = &NamedType {
name: "Arc<T>",
ty: T::SCHEMA.ty,
};
}
3 changes: 3 additions & 0 deletions source/postcard-schema/tests/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,9 @@ fn smoke() {
(dewit::<Option<Classic>>, "Option<Classic>"),
(dewit::<Option<ClassicGen<i32>>>, "Option<ClassicGen>"),
(dewit::<PathBuf>, "String"),
(dewit::<std::collections::VecDeque<u32>>, "[u32]"),
(dewit::<std::rc::Rc<u32>>, "u32"),
(dewit::<std::sync::Arc<u32>>, "u32"),
];
for (f, s) in tests {
assert_eq!(f().as_str(), *s);
Expand Down
Loading