Trait TakeRecur

Source
pub trait TakeRecur {
    type Inner;

    // Required method
    fn take_recur(self) -> Self::Inner;
}
Expand description

A trait for taking inner value out.

Various types have methods like take() to take something out by consuming the type itself. If the taken value also can be unwrapped, then clients need to write code like take().take(). This trait helps to avoid something like that and replace it with just one call.

§Examples

use my_ecs::prelude::TakeRecur;

struct A(B);
struct B(C);
struct C(i32);

impl TakeRecur for A
where
    B: TakeRecur
{
    type Inner = <B as TakeRecur>::Inner;
    fn take_recur(self) -> Self::Inner { self.0.take_recur() }
}

impl TakeRecur for B
where
    C: TakeRecur,
{
    type Inner = <C as TakeRecur>::Inner;
    fn take_recur(self) -> Self::Inner { self.0.take_recur() }
}

impl TakeRecur for C {
    type Inner = i32;
    fn take_recur(self) -> Self::Inner { self.0 }
}

let value = A(B(C(42)));
assert_eq!(value.take_recur(), 42);

Required Associated Types§

Required Methods§

Source

fn take_recur(self) -> Self::Inner

Takes out inner value recursively then returns it.

§Examples

See TakeRecur documentation.

Implementations on Foreign Types§

Source§

impl<A0: TakeRecur, A1: TakeRecur> TakeRecur for (A0, A1)

Source§

type Inner = (<A0 as TakeRecur>::Inner, <A1 as TakeRecur>::Inner)

Source§

fn take_recur(self) -> Self::Inner

Source§

impl<A0: TakeRecur, A1: TakeRecur, A2: TakeRecur> TakeRecur for (A0, A1, A2)

Source§

type Inner = (<A0 as TakeRecur>::Inner, <A1 as TakeRecur>::Inner, <A2 as TakeRecur>::Inner)

Source§

fn take_recur(self) -> Self::Inner

Source§

impl<A0: TakeRecur, A1: TakeRecur, A2: TakeRecur, A3: TakeRecur> TakeRecur for (A0, A1, A2, A3)

Source§

type Inner = (<A0 as TakeRecur>::Inner, <A1 as TakeRecur>::Inner, <A2 as TakeRecur>::Inner, <A3 as TakeRecur>::Inner)

Source§

fn take_recur(self) -> Self::Inner

Source§

impl<A0: TakeRecur, A1: TakeRecur, A2: TakeRecur, A3: TakeRecur, A4: TakeRecur> TakeRecur for (A0, A1, A2, A3, A4)

Source§

type Inner = (<A0 as TakeRecur>::Inner, <A1 as TakeRecur>::Inner, <A2 as TakeRecur>::Inner, <A3 as TakeRecur>::Inner, <A4 as TakeRecur>::Inner)

Source§

fn take_recur(self) -> Self::Inner

Source§

impl<A0: TakeRecur, A1: TakeRecur, A2: TakeRecur, A3: TakeRecur, A4: TakeRecur, A5: TakeRecur> TakeRecur for (A0, A1, A2, A3, A4, A5)

Source§

type Inner = (<A0 as TakeRecur>::Inner, <A1 as TakeRecur>::Inner, <A2 as TakeRecur>::Inner, <A3 as TakeRecur>::Inner, <A4 as TakeRecur>::Inner, <A5 as TakeRecur>::Inner)

Source§

fn take_recur(self) -> Self::Inner

Source§

impl<A0: TakeRecur, A1: TakeRecur, A2: TakeRecur, A3: TakeRecur, A4: TakeRecur, A5: TakeRecur, A6: TakeRecur> TakeRecur for (A0, A1, A2, A3, A4, A5, A6)

Source§

type Inner = (<A0 as TakeRecur>::Inner, <A1 as TakeRecur>::Inner, <A2 as TakeRecur>::Inner, <A3 as TakeRecur>::Inner, <A4 as TakeRecur>::Inner, <A5 as TakeRecur>::Inner, <A6 as TakeRecur>::Inner)

Source§

fn take_recur(self) -> Self::Inner

Source§

impl<A0: TakeRecur, A1: TakeRecur, A2: TakeRecur, A3: TakeRecur, A4: TakeRecur, A5: TakeRecur, A6: TakeRecur, A7: TakeRecur> TakeRecur for (A0, A1, A2, A3, A4, A5, A6, A7)

Source§

type Inner = (<A0 as TakeRecur>::Inner, <A1 as TakeRecur>::Inner, <A2 as TakeRecur>::Inner, <A3 as TakeRecur>::Inner, <A4 as TakeRecur>::Inner, <A5 as TakeRecur>::Inner, <A6 as TakeRecur>::Inner, <A7 as TakeRecur>::Inner)

Source§

fn take_recur(self) -> Self::Inner

Implementors§

Source§

impl<'buf, EW: EntQueryMut> TakeRecur for EntWrite<'buf, EW>
where EW::Output<'buf>: TakeRecur,

Source§

type Inner = <<EW as EntQueryMut>::Output<'buf> as TakeRecur>::Inner

Source§

impl<'buf, R: Query> TakeRecur for Read<'buf, R>
where R::Output<'buf>: TakeRecur,

Source§

type Inner = <<R as Query>::Output<'buf> as TakeRecur>::Inner

Source§

impl<'buf, RR: ResQuery> TakeRecur for ResRead<'buf, RR>
where RR::Output<'buf>: TakeRecur,

Source§

type Inner = <<RR as ResQuery>::Output<'buf> as TakeRecur>::Inner

Source§

impl<'buf, RW: ResQueryMut> TakeRecur for ResWrite<'buf, RW>
where RW::Output<'buf>: TakeRecur,

Source§

type Inner = <<RW as ResQueryMut>::Output<'buf> as TakeRecur>::Inner

Source§

impl<'buf, W: QueryMut> TakeRecur for Write<'buf, W>
where W::Output<'buf>: TakeRecur,

Source§

type Inner = <<W as QueryMut>::Output<'buf> as TakeRecur>::Inner