Skip to main content

K1

Struct K1 

Source
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>

Source

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));
Source

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());
Source

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());
Source

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§

Source§

impl<Me: ?Sized + Kind1<T>, T> Clone for K1<Me, T>
where <Me as Kind1<T>>::Inner: Clone,

Source§

fn clone(&self) -> Self

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<Me: ?Sized + Kind1<T>, T> Debug for K1<Me, T>
where <Me as Kind1<T>>::Inner: Debug,

Source§

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

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

impl<C: Kind2<A, B>, A, B> From<K1<K2P1_1<C, A>, B>> for K2<C, A, B>

Source§

fn from(curried: K1<K2P1_1<C, A>, B>) -> Self

Converts to this type from the input type.
Source§

impl<C: Kind2<A, B>, A, B> From<K1<K2P1_2<C, B>, A>> for K2<C, A, B>

Source§

fn from(curried: K1<K2P1_2<C, B>, A>) -> Self

Converts to this type from the input type.
Source§

impl<C: Kind2<A, B>, A, B> From<K2<C, A, B>> for K1<K2P1_1<C, A>, B>

Source§

fn from(uncurried: K2<C, A, B>) -> Self

Converts to this type from the input type.
Source§

impl<C: Kind2<A, B>, A, B> From<K2<C, A, B>> for K1<K2P1_2<C, B>, A>

Source§

fn from(uncurried: K2<C, A, B>) -> Self

Converts to this type from the input type.
Source§

impl<Me: ?Sized + Kind1<T>, T> PartialEq for K1<Me, T>
where <Me as Kind1<T>>::Inner: PartialEq,

Source§

fn eq(&self, other: &Self) -> 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.

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>
where Me: Unpin + ?Sized, T: Unpin,

§

impl<Me, T> UnsafeUnpin for K1<Me, T>
where Me: ?Sized,

§

impl<Me, T> UnwindSafe for K1<Me, T>
where Me: UnwindSafe + ?Sized, 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<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<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.