Skip to main content

LogosIndex

Trait LogosIndex 

Source
pub trait LogosIndex<I> {
    type Output;

    // Required method
    fn logos_get(&self, index: I) -> Self::Output;
}
Expand description

Immutable element access by index.

Provides 1-based indexing for Logos collections. Index 1 refers to the first element, index 2 to the second, and so on.

§Examples

use logicaffeine_data::LogosIndex;

let v = vec!["a", "b", "c"];
assert_eq!(v.logos_get(1i64), "a");  // 1-based!
assert_eq!(v.logos_get(3i64), "c");

§Panics

Panics if the index is less than 1 or greater than the collection length.

Required Associated Types§

Source

type Output

The type of element returned by indexing.

Required Methods§

Source

fn logos_get(&self, index: I) -> Self::Output

Get the element at the given index.

Implementations on Foreign Types§

Source§

impl<K: Eq + Hash, V: Clone> LogosIndex<K> for HashMap<K, V>

Source§

type Output = V

Source§

fn logos_get(&self, key: K) -> V

Source§

impl<T: Clone> LogosIndex<i64> for Vec<T>

Source§

type Output = T

Source§

fn logos_get(&self, index: i64) -> T

Source§

impl<V: Clone> LogosIndex<&str> for HashMap<String, V>

Source§

type Output = V

Source§

fn logos_get(&self, key: &str) -> V

Implementors§