pub struct AsVec<T, U, SU>(pub T, pub PhantomData<U>, pub PhantomData<SU>);Expand description
A wrapper that causes the wrapped container to be serialized as a Vec
collected from its iterated values.
The item type of the container needs to be given as the second type parameter.
use std::collections::BTreeMap;
use idm::{AsVec, ColonPair, UnderlineSpaces};
type InlineMap = AsVec<
BTreeMap<String, UnderlineSpaces<String>>,
(String, UnderlineSpaces<String>),
ColonPair<String, UnderlineSpaces<String>>,
>;
assert_eq!(
idm::from_str::<Vec<InlineMap>>(
"title:Structure_and_Interpretation_of_Computer_Programs isbn:0262010771\n\
title:A_Mathematical_Theory_of_Communication doi:10.1002/j.1538-7305.1948.tb01338.x\n"
)
.unwrap(),
vec![
AsVec::new(BTreeMap::from([
("title".into(), UnderlineSpaces(
"Structure and Interpretation of Computer Programs".into())),
("isbn".into(), UnderlineSpaces("0262010771".into()))
])),
AsVec::new(BTreeMap::from([
("title".into(), UnderlineSpaces(
"A Mathematical Theory of Communication".into())),
("doi".into(), UnderlineSpaces(
"10.1002/j.1538-7305.1948.tb01338.x".into()))
])),
]
);Tuple Fields
0: T1: PhantomData<U>2: PhantomData<SU>Implementations
Trait Implementations
sourceimpl<'de, T: FromIterator<U>, U, SU: Into<U> + DeserializeOwned> Deserialize<'de> for AsVec<T, U, SU>
impl<'de, T: FromIterator<U>, U, SU: Into<U> + DeserializeOwned> Deserialize<'de> for AsVec<T, U, SU>
sourcefn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<T: Ord, U: Ord, SU: Ord> Ord for AsVec<T, U, SU>
impl<T: Ord, U: Ord, SU: Ord> Ord for AsVec<T, U, SU>
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<T: PartialEq, U: PartialEq, SU: PartialEq> PartialEq<AsVec<T, U, SU>> for AsVec<T, U, SU>
impl<T: PartialEq, U: PartialEq, SU: PartialEq> PartialEq<AsVec<T, U, SU>> for AsVec<T, U, SU>
sourceimpl<T: PartialOrd, U: PartialOrd, SU: PartialOrd> PartialOrd<AsVec<T, U, SU>> for AsVec<T, U, SU>
impl<T: PartialOrd, U: PartialOrd, SU: PartialOrd> PartialOrd<AsVec<T, U, SU>> for AsVec<T, U, SU>
sourcefn partial_cmp(&self, other: &AsVec<T, U, SU>) -> Option<Ordering>
fn partial_cmp(&self, other: &AsVec<T, U, SU>) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moresourceimpl<T: Clone + IntoIterator<Item = U>, U, SU: Serialize + From<U>> Serialize for AsVec<T, U, SU>
impl<T: Clone + IntoIterator<Item = U>, U, SU: Serialize + From<U>> Serialize for AsVec<T, U, SU>
impl<T: Copy, U: Copy, SU: Copy> Copy for AsVec<T, U, SU>
impl<T: Eq, U: Eq, SU: Eq> Eq for AsVec<T, U, SU>
impl<T, U, SU> StructuralEq for AsVec<T, U, SU>
impl<T, U, SU> StructuralPartialEq for AsVec<T, U, SU>
Auto Trait Implementations
impl<T, U, SU> RefUnwindSafe for AsVec<T, U, SU>where
SU: RefUnwindSafe,
T: RefUnwindSafe,
U: RefUnwindSafe,
impl<T, U, SU> Send for AsVec<T, U, SU>where
SU: Send,
T: Send,
U: Send,
impl<T, U, SU> Sync for AsVec<T, U, SU>where
SU: Sync,
T: Sync,
U: Sync,
impl<T, U, SU> Unpin for AsVec<T, U, SU>where
SU: Unpin,
T: Unpin,
U: Unpin,
impl<T, U, SU> UnwindSafe for AsVec<T, U, SU>where
SU: UnwindSafe,
T: UnwindSafe,
U: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more