pub enum Spec<'a> {
Text(&'a str),
Notation(&'a EinsumNotation),
Subscripts(&'a EinsumSubscripts),
}Expand description
An einsum specification: text, parsed notation or integer subscripts.
Construction never fails; the text is parsed and every form is validated
inside the operation, which reports a malformed spec as an
InvalidSubscripts cause with kind Validation(InvalidArgument).
§Examples
use tenferro_einsum::{EinsumNotation, EinsumSubscripts, Spec};
let text: Spec<'_> = "ij,jk->ik".into();
assert!(matches!(text, Spec::Text("ij,jk->ik")));
let notation = EinsumNotation::parse("ij->ji")?;
assert!(matches!(Spec::from(¬ation), Spec::Notation(_)));
let subscripts = EinsumSubscripts::new(&[&[0, 1]], &[1, 0]);
assert!(matches!(Spec::from(&subscripts), Spec::Subscripts(_)));Variants§
Text(&'a str)
NumPy-style text such as "ij,jk->ik", parsed inside the operation.
Notation(&'a EinsumNotation)
Parsed notation, possibly with ellipses.
Subscripts(&'a EinsumSubscripts)
Integer subscripts without ellipses.
Trait Implementations§
impl<'a> Copy for Spec<'a>
Source§impl EinsumSpec for Spec<'_>
impl EinsumSpec for Spec<'_>
Source§impl<'a> From<&'a EinsumNotation> for Spec<'a>
impl<'a> From<&'a EinsumNotation> for Spec<'a>
Source§fn from(notation: &'a EinsumNotation) -> Self
fn from(notation: &'a EinsumNotation) -> Self
Converts to this type from the input type.
Source§impl<'a> From<&'a EinsumSubscripts> for Spec<'a>
impl<'a> From<&'a EinsumSubscripts> for Spec<'a>
Source§fn from(subscripts: &'a EinsumSubscripts) -> Self
fn from(subscripts: &'a EinsumSubscripts) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl<'a> Freeze for Spec<'a>
impl<'a> RefUnwindSafe for Spec<'a>
impl<'a> Send for Spec<'a>
impl<'a> Sync for Spec<'a>
impl<'a> Unpin for Spec<'a>
impl<'a> UnsafeUnpin for Spec<'a>
impl<'a> UnwindSafe for Spec<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more