Broadcast

Trait Broadcast 

Source
pub trait Broadcast<Other: Index>: Index {
    type Result: Index;

    // Required methods
    fn size(
        self_size: Self::Size,
        other_size: Other::Size,
    ) -> <Self::Result as Index>::Size;
    fn index(index: Self::Result) -> (Self, Other);
}
Expand description

Self implements Broadcast<Other> to say what happens when you zip a View indexed by Self with one indexed by Other.

Roughly speaking, each axis of self must be the same type and size as the corresponding axis of other, or one of them must be (). In the latter case, the sole array element of the smaller View will be replicated to fill out the size of the larger View. This is called “broadcasting”.

Required Associated Types§

Source

type Result: Index

The Resulting Index type.

Required Methods§

Source

fn size( self_size: Self::Size, other_size: Other::Size, ) -> <Self::Result as Index>::Size

The size of Self::Result, given the sizes of Self and Other.

Source

fn index(index: Self::Result) -> (Self, Other)

Where each Self::Result maps from in Self and in Other.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<IA, JA: Index> Broadcast<(JA,)> for (IA,)
where IA: Broadcast<JA> + Index,

Source§

type Result = (<IA as Broadcast<JA>>::Result,)

Source§

fn size( i_size: (IA::Size,), j_size: (JA::Size,), ) -> <Self::Result as Index>::Size

Source§

fn index(index: Self::Result) -> ((IA,), (JA,))

Source§

impl<IA, JA: Index, IB, JB: Index> Broadcast<(JA, JB)> for (IA, IB)
where IA: Broadcast<JA> + Index, IB: Broadcast<JB> + Index,

Source§

type Result = (<IA as Broadcast<JA>>::Result, <IB as Broadcast<JB>>::Result)

Source§

fn size( i_size: (IA::Size, IB::Size), j_size: (JA::Size, JB::Size), ) -> <Self::Result as Index>::Size

Source§

fn index(index: Self::Result) -> ((IA, IB), (JA, JB))

Source§

impl<IA, JA: Index, IB, JB: Index, IC, JC: Index> Broadcast<(JA, JB, JC)> for (IA, IB, IC)
where IA: Broadcast<JA> + Index, IB: Broadcast<JB> + Index, IC: Broadcast<JC> + Index,

Source§

type Result = (<IA as Broadcast<JA>>::Result, <IB as Broadcast<JB>>::Result, <IC as Broadcast<JC>>::Result)

Source§

fn size( i_size: (IA::Size, IB::Size, IC::Size), j_size: (JA::Size, JB::Size, JC::Size), ) -> <Self::Result as Index>::Size

Source§

fn index(index: Self::Result) -> ((IA, IB, IC), (JA, JB, JC))

Source§

impl<J: Expand> Broadcast<J> for ()

Source§

type Result = J

Source§

fn size(_: (), other_size: J::Size) -> J::Size

Source§

fn index(index: J) -> ((), J)

Implementors§

Source§

impl<I: Index + NonTuple> Broadcast<I> for I

Source§

impl<I: Expand> Broadcast<()> for I