pub struct Var<'a, S: VarScheme + ?Sized> { /* private fields */ }Expand description
One variable of a VarScheme, which is to say a scheme together with an index.
It is returned by VarScheme::var, and it is what a variable’s name is written from: it
implements Display, ToLatex, and ToTypst.
Implementations§
Source§impl<'a, S: VarScheme + ?Sized> Var<'a, S>
impl<'a, S: VarScheme + ?Sized> Var<'a, S>
Sourcepub const fn new(scheme: &'a S, index: usize) -> Self
pub const fn new(scheme: &'a S, index: usize) -> Self
Makes a handle to one of a scheme’s variables.
VarScheme::var is the shorter way to say this, and works whenever the scheme’s type is
known. This one also works for a scheme behind a dyn.
§Worst-case complexity
Constant time and additional memory.
§Examples
use malachite_base::vars::abc::AbcVars;
use malachite_base::vars::{Var, VarScheme};
let scheme: &dyn VarScheme = &AbcVars;
assert_eq!(Var::new(scheme, 2).to_string(), "c");Trait Implementations§
impl<S: VarScheme + ?Sized> Copy for Var<'_, S>
Source§impl<S: VarScheme + ?Sized> Debug for Var<'_, S>
impl<S: VarScheme + ?Sized> Debug for Var<'_, S>
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Converts a variable to a String.
This is the same as the Display implementation: a variable is its name, and a scheme is
not required to have a depiction of its own.
§Worst-case complexity
Same as the time and additional memory complexity of fmt_var for the scheme.
§Examples
use malachite_base::strings::ToDebugString;
use malachite_base::vars::VarScheme;
use malachite_base::vars::indexed::IndexedVars;
assert_eq!(IndexedVars.var(10).to_debug_string(), "x₁₀");Source§impl<S: VarScheme + ?Sized> Display for Var<'_, S>
impl<S: VarScheme + ?Sized> Display for Var<'_, S>
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Converts a variable to a String.
This is the plain name, the one VarScheme::parse_var reads back.
§Worst-case complexity
Same as the time and additional memory complexity of fmt_var for the scheme.
§Examples
use malachite_base::vars::VarScheme;
use malachite_base::vars::indexed::IndexedVars;
assert_eq!(IndexedVars.var(10).to_string(), "x₁₀");Source§impl<S: VarScheme + ?Sized> ToLatex for Var<'_, S>
impl<S: VarScheme + ?Sized> ToLatex for Var<'_, S>
Source§fn fmt_latex(&self, f: &mut Formatter<'_>) -> Result
fn fmt_latex(&self, f: &mut Formatter<'_>) -> Result
Writes a variable as a LaTeX math-mode fragment.
§Worst-case complexity
Same as the time and additional memory complexity of fmt_var_latex for the scheme.
§Examples
use malachite_base::strings::latex::ToLatex;
use malachite_base::vars::VarScheme;
use malachite_base::vars::greek::GreekVars;
use malachite_base::vars::indexed::IndexedVars;
assert_eq!(IndexedVars.var(10).to_latex_string(), "x_{10}");
assert_eq!(GreekVars.var(0).to_latex_string(), r"\alpha");Those fragments render as $x_{10}$ and $\alpha$.
Source§impl<S: VarScheme + ?Sized> ToTypst for Var<'_, S>
impl<S: VarScheme + ?Sized> ToTypst for Var<'_, S>
Source§fn fmt_typst(&self, f: &mut Formatter<'_>) -> Result
fn fmt_typst(&self, f: &mut Formatter<'_>) -> Result
Writes a variable as a Typst math-mode fragment.
§Worst-case complexity
Same as the time and additional memory complexity of fmt_var_typst for the scheme.
§Examples
use malachite_base::strings::typst::ToTypst;
use malachite_base::vars::VarScheme;
use malachite_base::vars::greek::GreekVars;
use malachite_base::vars::indexed::IndexedVars;
assert_eq!(IndexedVars.var(10).to_typst_string(), "x_(10)");
assert_eq!(GreekVars.var(0).to_typst_string(), "α");Auto Trait Implementations§
impl<'a, S> Freeze for Var<'a, S>
impl<'a, S> RefUnwindSafe for Var<'a, S>
impl<'a, S> Send for Var<'a, S>
impl<'a, S> Sync for Var<'a, S>
impl<'a, S> Unpin for Var<'a, S>
impl<'a, S> UnsafeUnpin for Var<'a, S>
impl<'a, S> UnwindSafe for Var<'a, S>
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
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,
Source§impl<T, U> ImaginaryInto<U> for Twhere
U: ImaginaryFrom<T>,
impl<T, U> ImaginaryInto<U> for Twhere
U: ImaginaryFrom<T>,
fn imaginary_into(self) -> 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> ⓘ
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> ⓘ
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