Skip to content
Merged
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
12 changes: 12 additions & 0 deletions src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use crate::prelude::{
collections::{
BTreeMap,
BTreeSet,
VecDeque,
},
marker::PhantomData,
string::String,
Expand Down Expand Up @@ -126,6 +127,17 @@ where
}
}

impl<T> TypeInfo for VecDeque<T>
where
T: TypeInfo + 'static,
{
type Identity = Vec<T>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not type Identity = [T]; here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, it should be this in order that [T], Vec<T> and VecDeque<T> all point to the same type

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


fn type_info() -> Type {
Self::Identity::type_info()
}
}

impl<T> TypeInfo for Option<T>
where
T: TypeInfo + 'static,
Expand Down
5 changes: 5 additions & 0 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ fn collections() {
.type_params(tuple_meta_type![String])
.composite(Fields::unnamed().field(|f| f.ty::<[String]>()))
);

assert_type!(
std::collections::VecDeque<String>,
TypeDefSequence::new(meta_type::<String>())
);
}

#[test]
Expand Down