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: AsRef<str>>(name: S) -> Self
pub fn new<S: AsRef<str>>(name: S) -> Self
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: AsRef<str>>(name: S) -> Self
pub fn scalar<S: AsRef<str>>(name: S) -> Self
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: AsRef<str>>(name: S) -> Self
pub fn matrix<S: AsRef<str>>(name: S) -> Self
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: AsRef<str>>(name: S) -> Self
pub fn operator<S: AsRef<str>>(name: S) -> Self
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: AsRef<str>>(name: S) -> Self
pub fn quaternion<S: AsRef<str>>(name: S) -> Self
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<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::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
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§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)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