Trait nom::lib::std::ops::Index 1.0.0[−][src]
pub trait Index<Idx> where
Idx: ?Sized, { type Output: ?Sized; pub fn index(&self, index: Idx) -> &Self::Output; }
Used for indexing operations (container[index]
) in immutable contexts.
container[index]
is actually syntactic sugar for *container.index(index)
,
but only when used as an immutable value. If a mutable value is requested,
IndexMut
is used instead. This allows nice things such as
let value = v[index]
if the type of value
implements Copy
.
Examples
The following example implements Index
on a read-only NucleotideCount
container, enabling individual counts to be retrieved with index syntax.
use std::ops::Index; enum Nucleotide { A, C, G, T, } struct NucleotideCount { a: usize, c: usize, g: usize, t: usize, } impl Index<Nucleotide> for NucleotideCount { type Output = usize; fn index(&self, nucleotide: Nucleotide) -> &Self::Output { match nucleotide { Nucleotide::A => &self.a, Nucleotide::C => &self.c, Nucleotide::G => &self.g, Nucleotide::T => &self.t, } } } let nucleotide_count = NucleotideCount {a: 14, c: 9, g: 10, t: 12}; assert_eq!(nucleotide_count[Nucleotide::A], 14); assert_eq!(nucleotide_count[Nucleotide::C], 9); assert_eq!(nucleotide_count[Nucleotide::G], 10); assert_eq!(nucleotide_count[Nucleotide::T], 12);
Associated Types
Required methods
Implementations on Foreign Types
impl Index<RangeFull> for CString
[src]
impl Index<RangeFull> for CString
[src]impl Index<RangeFull> for OsString
[src]
impl Index<RangeFull> for OsString
[src]impl Index<RangeFrom<usize>> for CStr
[src]
impl Index<RangeFrom<usize>> for CStr
[src]impl<I> Index<I> for str where
I: SliceIndex<str>,
[src]
impl<I> Index<I> for str where
I: SliceIndex<str>,
[src]type Output = <I as SliceIndex<str>>::Output
pub fn index(&self, index: I) -> &<I as SliceIndex<str>>::Output
[src]
impl<T, I> Index<I> for [T] where
I: SliceIndex<[T]>,
[src]
impl<T, I> Index<I> for [T] where
I: SliceIndex<[T]>,
[src]impl<T, I, const N: usize> Index<I> for [T; N] where
[T]: Index<I>,
[src]
impl<T, I, const N: usize> Index<I> for [T; N] where
[T]: Index<I>,
[src]Implementors
impl Index<RangeInclusive<usize>> for String
1.26.0[src]
impl Index<RangeInclusive<usize>> for String
1.26.0[src]impl Index<RangeToInclusive<usize>> for String
1.26.0[src]
impl Index<RangeToInclusive<usize>> for String
1.26.0[src]impl<'_, K, Q, V> Index<&'_ Q> for BTreeMap<K, V> where
K: Borrow<Q> + Ord,
Q: Ord + ?Sized,
[src]
impl<'_, K, Q, V> Index<&'_ Q> for BTreeMap<K, V> where
K: Borrow<Q> + Ord,
Q: Ord + ?Sized,
[src]impl<'_, K, Q, V, S> Index<&'_ Q> for HashMap<K, V, S> where
K: Eq + Hash + Borrow<Q>,
Q: Eq + Hash + ?Sized,
S: BuildHasher,
[src]
impl<'_, K, Q, V, S> Index<&'_ Q> for HashMap<K, V, S> where
K: Eq + Hash + Borrow<Q>,
Q: Eq + Hash + ?Sized,
S: BuildHasher,
[src]impl<T, S> Index<usize> for Rgb<T, S>
impl<T, S> Index<usize> for Rgb<T, S>
impl<T, C: AsRef<[T; 3]>> Index<usize> for AlphaColor<T, C>
impl<T, C: AsRef<[T; 3]>> Index<usize> for AlphaColor<T, C>
impl<T> Index<usize> for Vec3<T>
impl<T> Index<usize> for Vec3<T>
impl<K: Key, T> Index<K> for KeyedDenseVec<K, T>
impl<K: Key, T> Index<K> for KeyedDenseVec<K, T>
impl Index<usize> for FixedBitSet
impl Index<usize> for FixedBitSet
impl<T> Index<Index> for Arena<T>
impl<T> Index<Index> for Arena<T>
impl<'input, Endian> Index<usize> for EndianSlice<'input, Endian> where
Endian: Endianity,
impl<'input, Endian> Index<usize> for EndianSlice<'input, Endian> where
Endian: Endianity,
impl<'input, Endian> Index<RangeFrom<usize>> for EndianSlice<'input, Endian> where
Endian: Endianity,
impl<'input, Endian> Index<RangeFrom<usize>> for EndianSlice<'input, Endian> where
Endian: Endianity,
impl<I: Image> Index<u32> for Faces<I>
impl<I: Image> Index<u32> for Faces<I>
impl<K, Q: ?Sized, V, S> Index<&'_ Q> for HashMap<K, V, S> where
K: Eq + Hash + Borrow<Q>,
Q: Eq + Hash,
S: BuildHasher,
impl<K, Q: ?Sized, V, S> Index<&'_ Q> for HashMap<K, V, S> where
K: Eq + Hash + Borrow<Q>,
Q: Eq + Hash,
S: BuildHasher,
impl<Buffer> Index<(u8, u32, u32)> for FlatSamples<Buffer> where
Buffer: Index<usize>,
impl<Buffer> Index<(u8, u32, u32)> for FlatSamples<Buffer> where
Buffer: Index<usize>,
impl<P, Container> Index<(u32, u32)> for ImageBuffer<P, Container> where
P: Pixel + 'static,
P::Subpixel: 'static,
Container: Deref<Target = [P::Subpixel]>,
impl<P, Container> Index<(u32, u32)> for ImageBuffer<P, Container> where
P: Pixel + 'static,
P::Subpixel: 'static,
Container: Deref<Target = [P::Subpixel]>,
impl<T: Primitive> Index<usize> for Rgb<T>
impl<T: Primitive> Index<usize> for Rgb<T>
impl<T: Primitive> Index<usize> for Bgr<T>
impl<T: Primitive> Index<usize> for Bgr<T>
impl<T: Primitive> Index<usize> for Luma<T>
impl<T: Primitive> Index<usize> for Luma<T>
impl<T: Primitive> Index<usize> for Rgba<T>
impl<T: Primitive> Index<usize> for Rgba<T>
impl<T: Primitive> Index<usize> for Bgra<T>
impl<T: Primitive> Index<usize> for Bgra<T>
impl<T: Primitive> Index<usize> for LumaA<T>
impl<T: Primitive> Index<usize> for LumaA<T>
impl<K, V, Q: ?Sized, S> Index<&'_ Q> for IndexMap<K, V, S> where
Q: Hash + Equivalent<K>,
K: Hash + Eq,
S: BuildHasher,
impl<K, V, Q: ?Sized, S> Index<&'_ Q> for IndexMap<K, V, S> where
Q: Hash + Equivalent<K>,
K: Hash + Eq,
S: BuildHasher,
impl<K, V, S> Index<usize> for IndexMap<K, V, S>
impl<K, V, S> Index<usize> for IndexMap<K, V, S>
impl<T, S> Index<usize> for IndexSet<T, S>
impl<T, S> Index<usize> for IndexSet<T, S>
impl<N: Scalar, R: Dim, C: Dim, S: Storage<N, R, C>> Index<usize> for Matrix<N, R, C, S>
impl<N: Scalar, R: Dim, C: Dim, S: Storage<N, R, C>> Index<usize> for Matrix<N, R, C, S>
impl<N, R: Dim, C: Dim, S> Index<(usize, usize)> for Matrix<N, R, C, S> where
N: Scalar,
S: Storage<N, R, C>,
impl<N, R: Dim, C: Dim, S> Index<(usize, usize)> for Matrix<N, R, C, S> where
N: Scalar,
S: Storage<N, R, C>,
impl<N: Scalar, D: DimName> Index<usize> for Point<N, D> where
DefaultAllocator: Allocator<N, D>,
impl<N: Scalar, D: DimName> Index<usize> for Point<N, D> where
DefaultAllocator: Allocator<N, D>,
impl<N: Scalar, D: DimName> Index<(usize, usize)> for Rotation<N, D> where
DefaultAllocator: Allocator<N, D, D>,
impl<N: Scalar, D: DimName> Index<(usize, usize)> for Rotation<N, D> where
DefaultAllocator: Allocator<N, D, D>,
impl<N: Scalar> Index<usize> for Quaternion<N>
impl<N: Scalar> Index<usize> for Quaternion<N>
impl<N: SimdRealField> Index<usize> for DualQuaternion<N>
impl<N: SimdRealField> Index<usize> for DualQuaternion<N>
impl<N: RealField, D, C: TCategory> Index<(usize, usize)> for Transform<N, D, C> where
D: DimName + DimNameAdd<U1>,
DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>,
impl<N: RealField, D, C: TCategory> Index<(usize, usize)> for Transform<N, D, C> where
D: DimName + DimNameAdd<U1>,
DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>,
impl<N: RealField, T, BV> Index<DBVTLeafId> for DBVT<N, T, BV>
impl<N: RealField, T, BV> Index<DBVTLeafId> for DBVT<N, T, BV>
impl<N: RealField, T> Index<CollisionObjectSlabHandle> for CollisionObjectSlab<N, T>
impl<N: RealField, T> Index<CollisionObjectSlabHandle> for CollisionObjectSlab<N, T>
impl<'a, C> Index<&'a (usize, usize)> for Matrix<C>
impl<'a, C> Index<&'a (usize, usize)> for Matrix<C>
impl<N, E, Ty, Ix> Index<Ix> for Csr<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
impl<N, E, Ty, Ix> Index<Ix> for Csr<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
impl<N, E, Ty, Ix> Index<NodeIndex<Ix>> for Graph<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
impl<N, E, Ty, Ix> Index<NodeIndex<Ix>> for Graph<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
impl<N, E, Ty, Ix> Index<EdgeIndex<Ix>> for Graph<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
impl<N, E, Ty, Ix> Index<EdgeIndex<Ix>> for Graph<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
impl<'a, G, I> Index<I> for Frozen<'a, G> where
G: Index<I>,
impl<'a, G, I> Index<I> for Frozen<'a, G> where
G: Index<I>,
impl<N, E, Ty, Ix> Index<NodeIndex<Ix>> for StableGraph<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
impl<N, E, Ty, Ix> Index<NodeIndex<Ix>> for StableGraph<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
impl<N, E, Ty, Ix> Index<EdgeIndex<Ix>> for StableGraph<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
impl<N, E, Ty, Ix> Index<EdgeIndex<Ix>> for StableGraph<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
impl<N, E, Ty> Index<(N, N)> for GraphMap<N, E, Ty> where
N: NodeTrait,
Ty: EdgeType,
impl<N, E, Ty> Index<(N, N)> for GraphMap<N, E, Ty> where
N: NodeTrait,
Ty: EdgeType,
impl<N, E, Ty: EdgeType, Null: Nullable<Wrapped = E>, Ix: IndexType> Index<NodeIndex<Ix>> for MatrixGraph<N, E, Ty, Null, Ix>
impl<N, E, Ty: EdgeType, Null: Nullable<Wrapped = E>, Ix: IndexType> Index<NodeIndex<Ix>> for MatrixGraph<N, E, Ty, Null, Ix>
impl<N, E, Ty: EdgeType, Null: Nullable<Wrapped = E>, Ix: IndexType> Index<(NodeIndex<Ix>, NodeIndex<Ix>)> for MatrixGraph<N, E, Ty, Null, Ix>
impl<N, E, Ty: EdgeType, Null: Nullable<Wrapped = E>, Ix: IndexType> Index<(NodeIndex<Ix>, NodeIndex<Ix>)> for MatrixGraph<N, E, Ty, Null, Ix>
impl<'t> Index<usize> for Captures<'t>
impl<'t> Index<usize> for Captures<'t>
impl<'t, 'i> Index<&'i str> for Captures<'t>
impl<'t, 'i> Index<&'i str> for Captures<'t>
impl<'t> Index<usize> for Captures<'t>
impl<'t> Index<usize> for Captures<'t>
impl<'t, 'i> Index<&'i str> for Captures<'t>
impl<'t, 'i> Index<&'i str> for Captures<'t>
impl<T> Index<usize> for Mesh<T>
impl<T> Index<usize> for Mesh<T>
impl<'a, T> Index<usize> for MeshSlice<'a, T>
impl<'a, T> Index<usize> for MeshSlice<'a, T>
impl<T: RealField> Index<usize> for Polyline<T>
impl<T: RealField> Index<usize> for Polyline<T>
impl<'a, T: RealField> Index<usize> for PolylineSlice<'a, T>
impl<'a, T: RealField> Index<usize> for PolylineSlice<'a, T>
impl Index<TextureRef> for TexturesPool
impl Index<TextureRef> for TexturesPool
impl Index<CubemapRef> for TexturesPool
impl Index<CubemapRef> for TexturesPool
impl Index<SamplerRef> for TexturesPool
impl Index<SamplerRef> for TexturesPool
impl<M: Key> Index<M> for MaterialPool<M>
impl<M: Key> Index<M> for MaterialPool<M>
impl<M: Key> Index<M> for MaterialCache<M>
impl<M: Key> Index<M> for MaterialCache<M>
impl Index<ProgramRef> for ProgramCache
impl Index<ProgramRef> for ProgramCache
impl Index<ShadowMapRef> for ShadowMapPool
impl Index<ShadowMapRef> for ShadowMapPool
impl<V: 'static, B: 'static> Index<AllocatorHandle<V, B>> for AllocatorsIndex
impl<V: 'static, B: 'static> Index<AllocatorHandle<V, B>> for AllocatorsIndex
impl<T> Index<NodeId> for Arena<T>
impl<T> Index<NodeId> for Arena<T>
impl Index<usize> for UniqueEntities
impl Index<usize> for UniqueEntities
impl<'a, T: Index<U> + Clone, U: Clone> Index<U> for Property<'a, T>
impl<'a, T: Index<U> + Clone, U: Clone> Index<U> for Property<'a, T>
impl<'a, T: Index<U> + Clone, U: Clone> Index<U> for PropertyLastValue<'a, T>
impl<'a, T: Index<U> + Clone, U: Clone> Index<U> for PropertyLastValue<'a, T>
impl<'a, Q: ?Sized> Index<&'a Q> for Map<String, Value> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
impl<'a, Q: ?Sized> Index<&'a Q> for Map<String, Value> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
impl<I> Index<I> for Value where
I: Index,
impl<I> Index<I> for Value where
I: Index,
impl<T> Index<usize> for Slab<T>
impl<T> Index<usize> for Slab<T>
impl<K: Key, V: Slottable> Index<K> for SlotMap<K, V>
impl<K: Key, V: Slottable> Index<K> for SlotMap<K, V>
impl<K: Key, V> Index<K> for DenseSlotMap<K, V>
impl<K: Key, V> Index<K> for DenseSlotMap<K, V>
impl<K: Key, V: Slottable> Index<K> for HopSlotMap<K, V>
impl<K: Key, V: Slottable> Index<K> for HopSlotMap<K, V>
impl<K: Key, V> Index<K> for SecondaryMap<K, V>
impl<K: Key, V> Index<K> for SecondaryMap<K, V>
impl<K, V, S> Index<K> for SparseSecondaryMap<K, V, S> where
K: Key,
S: BuildHasher,
impl<K, V, S> Index<K> for SparseSecondaryMap<K, V, S> where
K: Key,
S: BuildHasher,
impl<A: Array, I: SliceIndex<[A::Item]>> Index<I> for SmallVec<A>
impl<A: Array, I: SliceIndex<[A::Item]>> Index<I> for SmallVec<A>
impl<T, P> Index<usize> for Punctuated<T, P>
impl<T, P> Index<usize> for Punctuated<T, P>
impl<'a, Q: ?Sized> Index<&'a Q> for Map<String, Value> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
impl<'a, Q: ?Sized> Index<&'a Q> for Map<String, Value> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
impl<I> Index<I> for Value where
I: Index,
impl<I> Index<I> for Value where
I: Index,