AsDefault

Type Alias AsDefault 

Source
pub type AsDefault<T> = Cons<Skip<T>, Insert<T>>;
Expand description

Parse a T and replace it with its default value. This is a zero sized type. It can be used for no allocation replacement elements in a Vec since it has a optimization for zero-sized-types where it wont allocate any memory but just act as counter then.

§Example

let mut token_iter = "..........".to_token_iter();

let parsed = <Vec<AsDefault<Dot>>>::parser(&mut token_iter).unwrap();
assert_eq!(parsed.len(), 10);
// Vec's ZST optimization at work:
assert_eq!(parsed.capacity(), usize::MAX);
assert_tokens_eq!(parsed, ". . . . . . . . . .");

Aliased Type§

pub struct AsDefault<T> {
    pub first: Skip<T>,
    pub second: Insert<T>,
    pub third: Nothing,
    pub fourth: Nothing,
}

Fields§

§first: Skip<T>

The first value

§second: Insert<T>

The second value

§third: Nothing

The third value

§fourth: Nothing

The fourth value