pub struct Cond<E, F> { /* private fields */ }Expand description
Conditionally encodes an encodable.
§Examples
use encode::Encodable;
use encode::combinators::Cond;
use std::ffi::CStr;
let non_empty = |s:&&CStr| !s.is_empty();
let mut buf = Vec::new();
Cond::new(c"hello", non_empty).encode(&mut buf).unwrap();
assert_eq!(&buf, b"hello\0", "A non-empty CStr includes the null terminator");
buf.clear();
Cond::new(c"", non_empty).encode(&mut buf).unwrap();
assert_eq!(&buf, b"", "An empty CStr does not produce any output");Implementations§
Trait Implementations§
Source§impl<E: Ord, F: Ord> Ord for Cond<E, F>
impl<E: Ord, F: Ord> Ord for Cond<E, F>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<E: PartialOrd, F: PartialOrd> PartialOrd for Cond<E, F>
impl<E: PartialOrd, F: PartialOrd> PartialOrd for Cond<E, F>
impl<E: Eq, F: Eq> Eq for Cond<E, F>
impl<E, F> StructuralPartialEq for Cond<E, F>
Auto Trait Implementations§
impl<E, F> Freeze for Cond<E, F>
impl<E, F> RefUnwindSafe for Cond<E, F>where
E: RefUnwindSafe,
F: RefUnwindSafe,
impl<E, F> Send for Cond<E, F>
impl<E, F> Sync for Cond<E, F>
impl<E, F> Unpin for Cond<E, F>
impl<E, F> UnwindSafe for Cond<E, F>where
E: UnwindSafe,
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> EncodableSize for Twhere
T: Encodable<SizeEncoder>,
impl<T> EncodableSize for Twhere
T: Encodable<SizeEncoder>,
Source§fn encoded_size(&self) -> Result<usize, <T as Encodable<SizeEncoder>>::Error>
fn encoded_size(&self) -> Result<usize, <T as Encodable<SizeEncoder>>::Error>
Returns the size of the encoded form of
self. Read more