pub struct AttributePropertyOptionalSingletone<Marker = AttributePropertyOptionalSingletoneMarker>(/* private fields */);Expand description
A generic attribute property for switching on/off.
Has 3 states: None, Some( true ), Some( false ).
Defaults to None.
Unlike AttributePropertyOptionalBoolean, it “understands” on, off keywords during parsing.
For example: #[ attribute( on ) ] and #[ attribute( off )].
As a consequence, the property has two keywords.
Implementations§
Methods from Deref<Target = Option<bool>>§
1.0.0 · sourcepub fn as_ref(&self) -> Option<&T>
pub fn as_ref(&self) -> Option<&T>
Converts from &Option<T> to Option<&T>.
§Examples
Calculates the length of an Option<String> as an Option<usize>
without moving the String. The map method takes the self argument by value,
consuming the original, so this technique uses as_ref to first take an Option to a
reference to the value inside the original.
let text: Option<String> = Some("Hello, world!".to_string());
// First, cast `Option<String>` to `Option<&String>` with `as_ref`,
// then consume *that* with `map`, leaving `text` on the stack.
let text_length: Option<usize> = text.as_ref().map(|s| s.len());
println!("still can print text: {text:?}");1.75.0 · sourcepub fn as_slice(&self) -> &[T]
pub fn as_slice(&self) -> &[T]
Returns a slice of the contained value, if any. If this is None, an
empty slice is returned. This can be useful to have a single type of
iterator over an Option or slice.
Note: Should you have an Option<&T> and wish to get a slice of T,
you can unpack it via opt.map_or(&[], std::slice::from_ref).
§Examples
assert_eq!(
[Some(1234).as_slice(), None.as_slice()],
[&[1234][..], &[][..]],
);The inverse of this function is (discounting
borrowing) [_]::first:
for i in [Some(1234_u16), None] {
assert_eq!(i.as_ref(), i.as_slice().first());
}1.40.0 · sourcepub fn as_deref(&self) -> Option<&<T as Deref>::Target>where
T: Deref,
pub fn as_deref(&self) -> Option<&<T as Deref>::Target>where
T: Deref,
Converts from Option<T> (or &Option<T>) to Option<&T::Target>.
Leaves the original Option in-place, creating a new one with a reference
to the original one, additionally coercing the contents via Deref.
§Examples
let x: Option<String> = Some("hey".to_owned());
assert_eq!(x.as_deref(), Some("hey"));
let x: Option<String> = None;
assert_eq!(x.as_deref(), None);Trait Implementations§
source§impl<Marker, IntoT> Assign<AttributePropertyOptionalSingletone<Marker>, IntoT> for AttributePropertyOptionalSingletone<Marker>where
IntoT: Into<AttributePropertyOptionalSingletone<Marker>>,
impl<Marker, IntoT> Assign<AttributePropertyOptionalSingletone<Marker>, IntoT> for AttributePropertyOptionalSingletone<Marker>where
IntoT: Into<AttributePropertyOptionalSingletone<Marker>>,
source§impl<Marker> AttributePropertyComponent for AttributePropertyOptionalSingletone<Marker>where
Marker: AttributePropertyComponent,
impl<Marker> AttributePropertyComponent for AttributePropertyOptionalSingletone<Marker>where
Marker: AttributePropertyComponent,
source§impl<Marker: Clone> Clone for AttributePropertyOptionalSingletone<Marker>
impl<Marker: Clone> Clone for AttributePropertyOptionalSingletone<Marker>
source§fn clone(&self) -> AttributePropertyOptionalSingletone<Marker>
fn clone(&self) -> AttributePropertyOptionalSingletone<Marker>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl<Marker: Debug> Debug for AttributePropertyOptionalSingletone<Marker>
impl<Marker: Debug> Debug for AttributePropertyOptionalSingletone<Marker>
source§impl<Marker: Default> Default for AttributePropertyOptionalSingletone<Marker>
impl<Marker: Default> Default for AttributePropertyOptionalSingletone<Marker>
source§fn default() -> AttributePropertyOptionalSingletone<Marker>
fn default() -> AttributePropertyOptionalSingletone<Marker>
source§impl<Marker> Deref for AttributePropertyOptionalSingletone<Marker>
impl<Marker> Deref for AttributePropertyOptionalSingletone<Marker>
source§impl<Marker> From<AttributePropertyOptionalSingletone<Marker>> for Option<bool>
impl<Marker> From<AttributePropertyOptionalSingletone<Marker>> for Option<bool>
source§fn from(src: AttributePropertyOptionalSingletone<Marker>) -> Self
fn from(src: AttributePropertyOptionalSingletone<Marker>) -> Self
source§impl<Marker> From<bool> for AttributePropertyOptionalSingletone<Marker>
impl<Marker> From<bool> for AttributePropertyOptionalSingletone<Marker>
impl<Marker: Copy> Copy for AttributePropertyOptionalSingletone<Marker>
Auto Trait Implementations§
impl<Marker> Freeze for AttributePropertyOptionalSingletone<Marker>
impl<Marker> RefUnwindSafe for AttributePropertyOptionalSingletone<Marker>where
Marker: RefUnwindSafe,
impl<Marker> Send for AttributePropertyOptionalSingletone<Marker>where
Marker: Send,
impl<Marker> Sync for AttributePropertyOptionalSingletone<Marker>where
Marker: Sync,
impl<Marker> Unpin for AttributePropertyOptionalSingletone<Marker>where
Marker: Unpin,
impl<Marker> UnwindSafe for AttributePropertyOptionalSingletone<Marker>where
Marker: UnwindSafe,
Blanket Implementations§
source§impl<S> AssignWithType for S
impl<S> AssignWithType for S
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)