Struct UnkStaticData

Source
pub struct UnkStaticData<T, I> { /* private fields */ }

Implementations§

Source§

impl<T> UnkStaticData<T, AlwaysLockOnce>

Source

pub const fn new(a: T) -> Self

Source§

impl<T> UnkStaticData<T, AtomicU8>

Source

pub const fn new(a: T) -> Self

Source§

impl<T, I> UnkStaticData<T, I>
where Self: UnsafeGenericStaticData<T>,

Source

pub unsafe fn set_box(&self, v: Box<T>) -> Result<(), StaticErr<Box<T>>>

Source

pub unsafe fn set_raw(&self, v: T) -> Result<(), StaticErr<T>>

Source§

impl<T, I> UnkStaticData<T, I>
where Self: GenericStaticData<T>,

Source

pub fn set(&self, v: T) -> Result<(), StaticErr<T>>

Examples found in repository?
examples/slice.rs (line 32)
28fn main() {
29	assert_eq!(TEST.is_true(), false);
30	println!("OK #0 {:?}", TEST);
31	
32	let err = TEST.set(&10);
33	assert_eq!(TEST.is_true(), true);
34	println!("OK #1 {:?}, result: {:?}", TEST, err);
35}
More examples
Hide additional examples
examples/dyn.rs (line 32)
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}
examples/drop.rs (line 21)
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}
examples/data.rs (line 20)
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 fn replace(&self, v: T) -> Result<T, StaticErr<T>>

Examples found in repository?
examples/data.rs (line 29)
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 unsafe fn unsafe_replace(&self, v: T) -> T

Source

pub fn get<'a>(&'a self) -> &'a T

Source

pub fn ignore_initialize(&self) -> Result<(), IgnoreInitErr>

Source

pub fn ignore_initialize_dont_result(&self)

Source

pub fn is_init_state(&self) -> bool

Source

pub fn is_noinit_state(&self) -> bool

Trait Implementations§

Source§

impl<T, I> AsRef<T> for UnkStaticData<T, I>
where Self: GenericStaticData<T>,

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T, I> Debug for UnkStaticData<T, I>
where T: Debug, Self: GenericStaticData<T>,

Source§

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

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

impl<T, I> Deref for UnkStaticData<T, I>
where Self: GenericStaticData<T>,

Source§

type Target = T

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl<T, I> Display for UnkStaticData<T, I>
where T: Display, Self: GenericStaticData<T>,

Source§

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

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

impl<T> GenericStaticData<T> for UnkStaticData<T, AlwaysLockOnce>

Source§

fn set(&self, v: T) -> Result<(), StaticErr<T>>

Source§

fn replace(&self, v: T) -> Result<T, StaticErr<T>>

Source§

unsafe fn unsafe_replace(&self, v: T) -> T

Source§

fn get<'a>(&'a self) -> &'a T

Source§

fn ignore_initialize(&self) -> Result<(), IgnoreInitErr>

Source§

fn ignore_initialize_dont_result(&self)

Source§

fn is_init_state(&self) -> bool

Source§

fn is_noinit_state(&self) -> bool

Source§

impl<T> GenericStaticData<T> for UnkStaticData<T, AtomicU8>

Source§

fn set(&self, v: T) -> Result<(), StaticErr<T>>

Source§

fn replace(&self, v: T) -> Result<T, StaticErr<T>>

Source§

unsafe fn unsafe_replace(&self, v: T) -> T

Source§

fn get<'a>(&'a self) -> &'a T

Source§

fn ignore_initialize(&self) -> Result<(), IgnoreInitErr>

Source§

fn ignore_initialize_dont_result(&self)

Source§

fn is_init_state(&self) -> bool

Source§

fn is_noinit_state(&self) -> bool

Source§

impl<T> UnsafeGenericStaticData<T> for UnkStaticData<&'static T, AtomicU8>
where T: 'static,

Source§

unsafe fn set_box(&self, v: Box<T>) -> Result<(), StaticErr<Box<T>>>

Source§

unsafe fn set_raw(&self, v: T) -> Result<(), StaticErr<T>>

Source§

impl<T> UnsafeGenericStaticData<T> for UnkStaticData<T, AlwaysLockOnce>

Source§

unsafe fn set_box(&self, v: Box<T>) -> Result<(), StaticErr<Box<T>>>

Source§

unsafe fn set_raw(&self, v: T) -> Result<(), StaticErr<T>>

Source§

impl<T, I> Send for UnkStaticData<T, I>
where T: Sync + Send,

Source§

impl<T, I> Sync for UnkStaticData<T, I>
where T: Sync,

Auto Trait Implementations§

§

impl<T, I> !Freeze for UnkStaticData<T, I>

§

impl<T, I> !RefUnwindSafe for UnkStaticData<T, I>

§

impl<T, I> Unpin for UnkStaticData<T, I>
where I: Unpin, T: Unpin,

§

impl<T, I> UnwindSafe for UnkStaticData<T, I>
where I: UnwindSafe, 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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.