pub struct DefaultDash<T: Default>(pub T);Expand description
Wrapper that represents Default values with "-", allowing them in
contexts that cannot represent an empty value.
use idm::DefaultDash;
assert_eq!(
idm::from_str::<DefaultDash<String>>("-").unwrap(),
DefaultDash(String::default())
);
assert_eq!(
idm::from_str::<DefaultDash<String>>("xyzzy").unwrap(),
DefaultDash("xyzzy".to_string())
);
assert_eq!(
idm::to_string(&DefaultDash("xyzzy".to_string())).unwrap(),
"xyzzy"
);
assert_eq!(
idm::to_string(&DefaultDash(String::default())).unwrap(),
"-"
);Tuple Fields§
§0: TTrait Implementations§
Source§impl<T: Clone + Default> Clone for DefaultDash<T>
impl<T: Clone + Default> Clone for DefaultDash<T>
Source§fn clone(&self) -> DefaultDash<T>
fn clone(&self) -> DefaultDash<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Default + Default> Default for DefaultDash<T>
impl<T: Default + Default> Default for DefaultDash<T>
Source§fn default() -> DefaultDash<T>
fn default() -> DefaultDash<T>
Returns the “default value” for a type. Read more
Source§impl<T: Default> Deref for DefaultDash<T>
impl<T: Default> Deref for DefaultDash<T>
Source§impl<T: Default> DerefMut for DefaultDash<T>
impl<T: Default> DerefMut for DefaultDash<T>
Source§impl<'de, T: DeserializeOwned + Default> Deserialize<'de> for DefaultDash<T>
impl<'de, T: DeserializeOwned + Default> Deserialize<'de> for DefaultDash<T>
Source§fn 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
Source§impl<T: Ord + Default> Ord for DefaultDash<T>
impl<T: Ord + Default> Ord for DefaultDash<T>
Source§fn cmp(&self, other: &DefaultDash<T>) -> Ordering
fn cmp(&self, other: &DefaultDash<T>) -> Ordering
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<T: PartialOrd + Default> PartialOrd for DefaultDash<T>
impl<T: PartialOrd + Default> PartialOrd for DefaultDash<T>
impl<T: Copy + Default> Copy for DefaultDash<T>
impl<T: Eq + Default> Eq for DefaultDash<T>
impl<T: Default> StructuralPartialEq for DefaultDash<T>
Auto Trait Implementations§
impl<T> Freeze for DefaultDash<T>where
T: Freeze,
impl<T> RefUnwindSafe for DefaultDash<T>where
T: RefUnwindSafe,
impl<T> Send for DefaultDash<T>where
T: Send,
impl<T> Sync for DefaultDash<T>where
T: Sync,
impl<T> Unpin for DefaultDash<T>where
T: Unpin,
impl<T> UnwindSafe for DefaultDash<T>where
T: 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