AsIndex

Trait AsIndex 

Source
pub trait AsIndex:
    Debug
    + Copy
    + Sized {
    // Required method
    fn index(self) -> isize;
}
Expand description

Helper trait for implementing indexing with support for negative indices.

§Example

use burn_tensor::indexing::{AsIndex, canonicalize_dim};

fn example<I: AsIndex, const D: usize>(dim: I, size: usize) -> isize {
   let dim: usize = canonicalize_dim(dim, D, false);
   unimplemented!()
}

Required Methods§

Source

fn index(self) -> isize

Converts into a slice index.

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 AsIndex for i8

Source§

fn index(self) -> isize

Source§

impl AsIndex for i16

Source§

fn index(self) -> isize

Source§

impl AsIndex for i32

Source§

fn index(self) -> isize

Source§

impl AsIndex for i64

Source§

fn index(self) -> isize

Source§

impl AsIndex for isize

Source§

fn index(self) -> isize

Source§

impl AsIndex for u8

Source§

fn index(self) -> isize

Source§

impl AsIndex for u16

Source§

fn index(self) -> isize

Source§

impl AsIndex for u32

Source§

fn index(self) -> isize

Source§

impl AsIndex for u64

Source§

fn index(self) -> isize

Source§

impl AsIndex for usize

Source§

fn index(self) -> isize

Implementors§