Expand description
Named symbols for use in compute algebra systems. Symbol names are stored centrally such that copies are cheap and need little memory.
§Example
use math_symbols::*;
// Define a number of symbols with variable name equal to symbol name
symbols!(x, y, z);
assert_eq!(x.name(), "x");
assert_eq!(y.name(), "y");
assert_eq!(z.name(), "z");
// Symbols are identified by their names
let xx = Symbol::new("x");
assert_eq!(x, xx);
// Symbols are ordered by their creation time
assert!(x < y);
// We can generate symbol names dynamically. The allocated
// memory will be leaked if and only if a new symbol has to be created.
for i in 0..5 {
// leaks memory
let xi = Symbol::new(format!("x{i}"));
}
for i in 0..5 {
// does not leak any additional memory
let xi = Symbol::new(format!("x{i}"));
}§Features
serdeadds support for (de)serialisation with serde- By default each symbol is internally stored in a
u32. Hence, the total number of symbols is limited to 2^32. The featuresu8, u16, u64, u128, usizeenable symbolsSymbolu8, Symbolu16, Symbolu64, Symbolu128, Symbolusize, and macrossymbols_u8, symbols_u16, symbols_u64, symbols_u128, symbols_usizefor the corresponding storage type.
§Similar crates
Macros§
- impl_
symbol - symbols
- Construct variables with the same variable and symbol name
- symbols_
u32 - Construct variables with the same variable and symbol name
Structs§
- Symbolu32
- A symbol
Traits§
- Leak
- A type that can be leaked into a
T