pub struct Symbol {
pub name: Arc<str>,
/* private fields */
}Expand description
Mathematical symbol/variable with efficient string sharing
Fields§
§name: Arc<str>Implementations§
Source§impl Symbol
impl Symbol
Sourcepub fn new<S>(name: S) -> Symbol
pub fn new<S>(name: S) -> Symbol
Create a new scalar symbol (default behavior, backward compatible)
Note: Prefer using symbol!(x) macro in application code.
This method is kept for backward compatibility and internal use.
§Examples
use mathhook_core::symbol;
let x = symbol!(x);
let alpha = symbol!(alpha);Sourcepub fn scalar<S>(name: S) -> Symbol
pub fn scalar<S>(name: S) -> Symbol
Create a scalar symbol (commutative)
§Examples
use mathhook_core::core::symbol::Symbol;
use mathhook_core::core::commutativity::Commutativity;
let x = Symbol::scalar("x");
assert_eq!(x.commutativity(), Commutativity::Commutative);Sourcepub fn matrix<S>(name: S) -> Symbol
pub fn matrix<S>(name: S) -> Symbol
Create a matrix symbol (noncommutative)
§Examples
use mathhook_core::core::symbol::Symbol;
use mathhook_core::core::commutativity::Commutativity;
let A = Symbol::matrix("A");
assert_eq!(A.commutativity(), Commutativity::Noncommutative);Sourcepub fn operator<S>(name: S) -> Symbol
pub fn operator<S>(name: S) -> Symbol
Create an operator symbol (noncommutative)
§Examples
use mathhook_core::core::symbol::Symbol;
use mathhook_core::core::commutativity::Commutativity;
let p = Symbol::operator("p");
assert_eq!(p.commutativity(), Commutativity::Noncommutative);Sourcepub fn quaternion<S>(name: S) -> Symbol
pub fn quaternion<S>(name: S) -> Symbol
Create a quaternion symbol (noncommutative)
§Examples
use mathhook_core::core::symbol::Symbol;
use mathhook_core::core::commutativity::Commutativity;
let i = Symbol::quaternion("i");
assert_eq!(i.commutativity(), Commutativity::Noncommutative);Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Get the symbol name
§Examples
use mathhook_core::symbol;
let x = symbol!(x);
assert_eq!(x.name(), "x");Sourcepub fn symbol_type(&self) -> SymbolType
pub fn symbol_type(&self) -> SymbolType
Get the type of this symbol
§Examples
use mathhook_core::core::symbol::{Symbol, SymbolType};
let x = Symbol::scalar("x");
assert_eq!(x.symbol_type(), SymbolType::Scalar);
let A = Symbol::matrix("A");
assert_eq!(A.symbol_type(), SymbolType::Matrix);Sourcepub fn commutativity(&self) -> Commutativity
pub fn commutativity(&self) -> Commutativity
Get commutativity of this symbol
§Examples
use mathhook_core::core::symbol::Symbol;
use mathhook_core::core::commutativity::Commutativity;
let x = Symbol::scalar("x");
assert_eq!(x.commutativity(), Commutativity::Commutative);
let A = Symbol::matrix("A");
assert_eq!(A.commutativity(), Commutativity::Noncommutative);Trait Implementations§
Source§impl<'de> Deserialize<'de> for Symbol
impl<'de> Deserialize<'de> for Symbol
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Symbol, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Symbol, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<Symbol> for Expression
impl From<Symbol> for Expression
Source§fn from(symbol: Symbol) -> Expression
fn from(symbol: Symbol) -> Expression
Converts to this type from the input type.
Source§impl Serialize for Symbol
impl Serialize for Symbol
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Eq for Symbol
impl StructuralPartialEq for Symbol
Auto Trait Implementations§
impl Freeze for Symbol
impl RefUnwindSafe for Symbol
impl Send for Symbol
impl Sync for Symbol
impl Unpin for Symbol
impl UnwindSafe for Symbol
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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