Struct StaticErr

Source
pub struct StaticErr<T> { /* private fields */ }

Implementations§

Source§

impl<T> StaticErr<T>

Source

pub const fn new(arg: T, err: StaticInitErr) -> Self

Source

pub const fn prev(arg: T) -> Self

Examples found in repository?
examples/drop.rs (line 25)
20fn main() -> Result<(), StaticErr<MyDrop>> {
21	DROPPER.set(MyDrop(1))?;
22	println!("OK #0 this_value {:?}", DROPPER);
23	
24	let err = DROPPER.set(MyDrop(2));
25	assert_eq!(err, Err(StaticErr::prev(MyDrop(2))) );
26	println!("OK #1 this_value {:?}", DROPPER);
27	
28	let err = DROPPER.set(MyDrop(3));
29	assert_eq!(err, Err(StaticErr::prev(MyDrop(3))) );
30	println!("OK #2 this_value {:?}", DROPPER);
31	
32	Ok( () )
33}
More examples
Hide additional examples
examples/data.rs (line 30)
16fn main() {
17	assert_eq!(*TEST, TestValue::Unk);
18	println!("OK #1 {:?}", TEST);
19	
20	let result = TEST.set(TestValue::RuntimeValue(10));
21	assert_eq!(result.is_ok(), true);
22	println!("OK #2 {:?}", TEST);
23	
24	let result = TEST.set(TestValue::RuntimeValue(20));
25	assert_eq!(result.is_ok(), false);
26	assert_eq!(*TEST, TestValue::RuntimeValue(10));
27	println!("OK #3 {:?}", TEST);
28	
29	let result = TEST.replace(TestValue::Unk);
30	assert_eq!(result, Err(StaticErr::prev(TestValue::Unk)));
31	println!("OK #4 {:?}", result);
32}
Source

pub const fn allow(arg: T) -> Self

Source

pub const fn unk(arg: T) -> Self

Source

pub fn into_inner(self) -> T

Examples found in repository?
examples/dyn.rs (line 36)
31fn main() -> Result<(), StaticErr<&'static (dyn MyTrait + 'static)>> {
32	let _result = TEST.set(&10)?;
33	println!("OK {:?}, data: {:?}", TEST, TEST.data());
34	
35	let err = TEST.set(&20);
36	assert_eq!(err.err().unwrap().into_inner().data(), 20);
37	println!("OK {:?}, data: {:?}", TEST, TEST.data());
38	
39	Ok( () )
40}
Source

pub fn into_type(self) -> StaticInitErr

Source

pub const fn as_type(&self) -> &StaticInitErr

Source

pub const fn as_inner(&self) -> &T

Trait Implementations§

Source§

impl<T: Clone> Clone for StaticErr<T>

Source§

fn clone(&self) -> StaticErr<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for StaticErr<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Deref for StaticErr<T>

Source§

type Target = StaticInitErr

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T> DerefMut for StaticErr<T>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<T> From<(T, StaticInitErr)> for StaticErr<T>

Source§

fn from((v, t): (T, StaticInitErr)) -> Self

Converts to this type from the input type.
Source§

impl<T> From<T> for StaticErr<T>

Source§

fn from(a: T) -> Self

Converts to this type from the input type.
Source§

impl<T: PartialEq> PartialEq for StaticErr<T>

Source§

fn eq(&self, other: &StaticErr<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PartialOrd> PartialOrd for StaticErr<T>

Source§

fn partial_cmp(&self, other: &StaticErr<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T> StructuralPartialEq for StaticErr<T>

Auto Trait Implementations§

§

impl<T> Freeze for StaticErr<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for StaticErr<T>
where T: RefUnwindSafe,

§

impl<T> Send for StaticErr<T>
where T: Send,

§

impl<T> Sync for StaticErr<T>
where T: Sync,

§

impl<T> Unpin for StaticErr<T>
where T: Unpin,

§

impl<T> UnwindSafe for StaticErr<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<!> for T

Source§

fn from(t: !) -> T

Converts to this type from the input type.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.