pub fn serialize<T, S>(
    options: &T,
    serializer: S,
) -> Result<S::Ok, S::Error>
where
    T: OptionSet,
    S: Serializer,
{
    let mut seq = if !serializer.is_human_readable() {
        let mut count = 0;
        for &variant in T::VARIANTS {
            if *options & variant == variant {
                count += 1;
            }
        }
        let mut s = serializer.serialize_seq(Some(count + 1))?;
        s.serialize_element(&(count as u64))?;
        s
    } else {
        serializer.serialize_seq(None)?
    };

    for (&variant, &name) in T::VARIANTS.iter().zip(T::NAMES) {
        if *options & variant == variant {
            seq.serialize_element(&name)?;
        }
    }

    seq.end()
}
/// Serialize an OptionSet's set bits as a sequence of strings.
Serialize an OptionSet's set bits as a sequence of strings.
Serialize an OptionSet ' s set bits as a sequence of strings .
pub fn serialize<T, S>(
    options: &T,
    serializer: S,
) -> Result<S::Ok, S::Error>
where
    T: OptionSet,
    S: Serializer,
{
    let mut seq = if !serializer.is_human_readable() {
        let mut count = 0;
        for &variant in T::VARIANTS {
            if *options & variant == variant {
                count += 1;
            }
        }
        let mut s = serializer.serialize_seq(Some(count + 1))?;
        s.serialize_element(&(count as u64))?;
        s
    } else {
        serializer.serialize_seq(None)?
    };
    for (&variant, &name) in T::VARIANTS.iter().zip(T::NAMES) {
        if *options & variant == variant {
            seq.serialize_element(&name)?;
        }
    }
    seq.end()
}
pub fn serialize < T , S > ( options : & T , serializer : S , ) -> Result < S :: Ok , S :: Error > where T : OptionSet , S : Serializer , { let mut seq = if ! serializer . is_human_readable ( ) { let mut count = 0 ; for & variant in T :: VARIANTS { if * options & variant == variant { count += 1 ; } } let mut s = serializer . serialize_seq ( Some ( count + 1 ) ) ? ; s . serialize_element ( & ( count as u64 ) ) ? ; s } else { serializer . serialize_seq ( None ) ? } ; for ( & variant , & name ) in T :: VARIANTS . iter ( ) . zip ( T :: NAMES ) { if * options & variant == variant { seq . serialize_element ( & name ) ? ; } } seq . end ( ) }
Serialize an OptionSet's set bits as a sequence of strings.
Serialize an OptionSet ' s set bits as a sequence of strings .
options
&T
serializer
S
options
&T
serializer
S