hasind

Function hasind 

Source
pub fn hasind<I: IndexLike>(indices: &[I], index: &I) -> bool
Expand description

Check if a collection contains a specific index (by ID).

This corresponds to ITensors.jl’s hasind function.

§Arguments

  • indices - Collection of indices to search
  • index - The index to look for

§Returns

true if an index with matching ID is found, false otherwise.

§Example

use tensor4all_core::index::{DefaultIndex as Index, DynId};
use tensor4all_core::index_ops::hasind;

let i = Index::new_dyn(2);
let j = Index::new_dyn(3);
let indices = vec![i.clone(), j.clone()];

assert!(hasind(&indices, &i));
assert!(!hasind(&indices, &Index::new_dyn(4)));