pub struct K1<Me: ?Sized, T> { /* private fields */ }Expand description
An instance of a type produced by a unary type constructor.
You can freely convert between the wrapper and implementation types
with new and the inner_* methods:
use lifted::types::OptionC;
let something: Option<i32> = Some(42);
let mut wrapped: K1<OptionC, i32> = K1::new(something);
assert!(wrapped.inner().is_some());
wrapped.inner_mut().take();
assert!(wrapped.into_inner().is_none());Implementations§
Source§impl<Me: ?Sized + Kind1<T>, T> K1<Me, T>
impl<Me: ?Sized + Kind1<T>, T> K1<Me, T>
Sourcepub fn new(t: <Me as Kind1<T>>::Inner) -> Self
pub fn new(t: <Me as Kind1<T>>::Inner) -> Self
Wrap an instance in the higher-kinded wrapper.
use lifted::types::OptionC;
let wrapped: K1<OptionC, i32> = K1::new(None);There is also an alias in the Kind1 trait which you
can use to produce a wrapped type.
let wrapped: K1<OptionC, i32> = OptionC::new(Some(42));Sourcepub fn inner(&self) -> &<Me as Kind1<T>>::Inner
pub fn inner(&self) -> &<Me as Kind1<T>>::Inner
Get a shared reference to the implementation type.
use lifted::types::OptionC;
let nothing: K1<OptionC, i32> = OptionC::new(None);
assert!(nothing.inner().is_none());Sourcepub fn inner_mut(&mut self) -> &mut <Me as Kind1<T>>::Inner
pub fn inner_mut(&mut self) -> &mut <Me as Kind1<T>>::Inner
Get an exclusive reference to the implementation type.
use lifted::types::OptionC;
let mut nothing: K1<OptionC, i32> = OptionC::new(None);
*nothing.inner_mut() = Some(42);
assert!(nothing.inner().is_some());Sourcepub fn into_inner(self) -> <Me as Kind1<T>>::Inner
pub fn into_inner(self) -> <Me as Kind1<T>>::Inner
Extract the implementation type from the wrapper.
use lifted::types::OptionC;
let wrapped: K1<OptionC, i32> = OptionC::new(Some(42));
let unwrapped = wrapped.into_inner();
assert_eq!(Some(42), unwrapped);Trait Implementations§
Auto Trait Implementations§
impl<Me, T> Freeze for K1<Me, T>where
Me: ?Sized,
impl<Me, T> RefUnwindSafe for K1<Me, T>
impl<Me, T> !Send for K1<Me, T>
impl<Me, T> !Sync for K1<Me, T>
impl<Me, T> Unpin for K1<Me, T>
impl<Me, T> UnsafeUnpin for K1<Me, T>where
Me: ?Sized,
impl<Me, T> UnwindSafe for K1<Me, T>
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