pub struct Context { /* private fields */ }
Expand description
A Context
holds a set of deduplicated constants, variables, and
operations.
It should be used like an arena allocator: it grows over time, then frees all of its contents when dropped. There is no reference counting within the context.
Items in the context are accessed with Node
keys, which are simple
handles into an internal map. Inside the context, operations are
represented with the Op
type.
Implementations§
Source§impl Context
impl Context
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears the context
All Node
handles from this context are invalidated.
let mut ctx = Context::new();
let x = ctx.x();
ctx.clear();
assert!(ctx.eval_xyz(x, 1.0, 0.0, 0.0).is_err());
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of Op
nodes in the context
let mut ctx = Context::new();
let x = ctx.x();
assert_eq!(ctx.len(), 1);
let y = ctx.y();
assert_eq!(ctx.len(), 2);
ctx.clear();
assert_eq!(ctx.len(), 0);
Sourcepub fn get_const(&self, n: Node) -> Result<f64, Error>
pub fn get_const(&self, n: Node) -> Result<f64, Error>
Looks up the constant associated with the given node.
If the node is invalid for this tree, returns an error; if the node is
not a constant, returns Ok(None)
.
Sourcepub fn get_var(&self, n: Node) -> Result<Var, Error>
pub fn get_var(&self, n: Node) -> Result<Var, Error>
Looks up the Var
associated with the given node.
If the node is invalid for this tree or not an Op::Input
, returns an
error.
Sourcepub fn x(&mut self) -> Node
pub fn x(&mut self) -> Node
Constructs or finds a Var::X
node
let mut ctx = Context::new();
let x = ctx.x();
let v = ctx.eval_xyz(x, 1.0, 0.0, 0.0).unwrap();
assert_eq!(v, 1.0);
Sourcepub fn var(&mut self, v: Var) -> Node
pub fn var(&mut self, v: Var) -> Node
Constructs or finds a variable input node
To make an anonymous variable, call this function with Var::new()
:
let mut ctx = Context::new();
let v1 = ctx.var(Var::new());
let v2 = ctx.var(Var::new());
assert_ne!(v1, v2);
let mut vars = HashMap::new();
vars.insert(ctx.get_var(v1).unwrap(), 3.0);
assert_eq!(ctx.eval(v1, &vars).unwrap(), 3.0);
assert!(ctx.eval(v2, &vars).is_err()); // v2 isn't in the map
Sourcepub fn constant(&mut self, f: f64) -> Node
pub fn constant(&mut self, f: f64) -> Node
Returns a node representing the given constant value.
let v = ctx.constant(3.0);
assert_eq!(ctx.eval_xyz(v, 0.0, 0.0, 0.0).unwrap(), 3.0);
Sourcepub fn add<A: IntoNode, B: IntoNode>(
&mut self,
a: A,
b: B,
) -> Result<Node, Error>
pub fn add<A: IntoNode, B: IntoNode>( &mut self, a: A, b: B, ) -> Result<Node, Error>
Builds an addition node
let x = ctx.x();
let op = ctx.add(x, 1.0).unwrap();
let v = ctx.eval_xyz(op, 1.0, 0.0, 0.0).unwrap();
assert_eq!(v, 2.0);
Sourcepub fn mul<A: IntoNode, B: IntoNode>(
&mut self,
a: A,
b: B,
) -> Result<Node, Error>
pub fn mul<A: IntoNode, B: IntoNode>( &mut self, a: A, b: B, ) -> Result<Node, Error>
Builds an multiplication node
let x = ctx.x();
let op = ctx.mul(x, 5.0).unwrap();
let v = ctx.eval_xyz(op, 2.0, 0.0, 0.0).unwrap();
assert_eq!(v, 10.0);
Sourcepub fn min<A: IntoNode, B: IntoNode>(
&mut self,
a: A,
b: B,
) -> Result<Node, Error>
pub fn min<A: IntoNode, B: IntoNode>( &mut self, a: A, b: B, ) -> Result<Node, Error>
Builds an min
node
let x = ctx.x();
let op = ctx.min(x, 5.0).unwrap();
let v = ctx.eval_xyz(op, 2.0, 0.0, 0.0).unwrap();
assert_eq!(v, 2.0);
Sourcepub fn max<A: IntoNode, B: IntoNode>(
&mut self,
a: A,
b: B,
) -> Result<Node, Error>
pub fn max<A: IntoNode, B: IntoNode>( &mut self, a: A, b: B, ) -> Result<Node, Error>
Builds an max
node
let x = ctx.x();
let op = ctx.max(x, 5.0).unwrap();
let v = ctx.eval_xyz(op, 2.0, 0.0, 0.0).unwrap();
assert_eq!(v, 5.0);
Sourcepub fn and<A: IntoNode, B: IntoNode>(
&mut self,
a: A,
b: B,
) -> Result<Node, Error>
pub fn and<A: IntoNode, B: IntoNode>( &mut self, a: A, b: B, ) -> Result<Node, Error>
Builds an and
node
If both arguments are non-zero, returns the right-hand argument. Otherwise, returns zero.
This node can be simplified using a tracing evaluator:
- If the left-hand argument is zero, simplify to just that argument
- If the left-hand argument is non-zero, simplify to the other argument
let x = ctx.x();
let y = ctx.y();
let op = ctx.and(x, y).unwrap();
let v = ctx.eval_xyz(op, 1.0, 0.0, 0.0).unwrap();
assert_eq!(v, 0.0);
let v = ctx.eval_xyz(op, 1.0, 1.0, 0.0).unwrap();
assert_eq!(v, 1.0);
let v = ctx.eval_xyz(op, 1.0, 2.0, 0.0).unwrap();
assert_eq!(v, 2.0);
Sourcepub fn or<A: IntoNode, B: IntoNode>(
&mut self,
a: A,
b: B,
) -> Result<Node, Error>
pub fn or<A: IntoNode, B: IntoNode>( &mut self, a: A, b: B, ) -> Result<Node, Error>
Builds an or
node
If the left-hand argument is non-zero, it is returned. Otherwise, the right-hand argument is returned.
This node can be simplified using a tracing evaluator.
let x = ctx.x();
let y = ctx.y();
let op = ctx.or(x, y).unwrap();
let v = ctx.eval_xyz(op, 1.0, 0.0, 0.0).unwrap();
assert_eq!(v, 1.0);
let v = ctx.eval_xyz(op, 0.0, 0.0, 0.0).unwrap();
assert_eq!(v, 0.0);
let v = ctx.eval_xyz(op, 0.0, 3.0, 0.0).unwrap();
assert_eq!(v, 3.0);
Sourcepub fn not<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
pub fn not<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
Builds a logical negation node
The output is 1 if the argument is 0, and 0 otherwise.
Sourcepub fn neg<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
pub fn neg<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
Builds a unary negation node
let x = ctx.x();
let op = ctx.neg(x).unwrap();
let v = ctx.eval_xyz(op, 2.0, 0.0, 0.0).unwrap();
assert_eq!(v, -2.0);
Sourcepub fn recip<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
pub fn recip<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
Builds a reciprocal node
let x = ctx.x();
let op = ctx.recip(x).unwrap();
let v = ctx.eval_xyz(op, 2.0, 0.0, 0.0).unwrap();
assert_eq!(v, 0.5);
Sourcepub fn abs<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
pub fn abs<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
Builds a node which calculates the absolute value of its input
let x = ctx.x();
let op = ctx.abs(x).unwrap();
let v = ctx.eval_xyz(op, 2.0, 0.0, 0.0).unwrap();
assert_eq!(v, 2.0);
let v = ctx.eval_xyz(op, -2.0, 0.0, 0.0).unwrap();
assert_eq!(v, 2.0);
Sourcepub fn sqrt<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
pub fn sqrt<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
Builds a node which calculates the square root of its input
let x = ctx.x();
let op = ctx.sqrt(x).unwrap();
let v = ctx.eval_xyz(op, 4.0, 0.0, 0.0).unwrap();
assert_eq!(v, 2.0);
Sourcepub fn sin<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
pub fn sin<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
Builds a node which calculates the sine of its input (in radians)
let x = ctx.x();
let op = ctx.sin(x).unwrap();
let v = ctx.eval_xyz(op, std::f64::consts::PI / 2.0, 0.0, 0.0).unwrap();
assert_eq!(v, 1.0);
Sourcepub fn cos<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
pub fn cos<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
Builds a node which calculates the cosine of its input (in radians)
Sourcepub fn tan<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
pub fn tan<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
Builds a node which calculates the tangent of its input (in radians)
Sourcepub fn asin<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
pub fn asin<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
Builds a node which calculates the arcsine of its input (in radians)
Sourcepub fn acos<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
pub fn acos<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
Builds a node which calculates the arccosine of its input (in radians)
Sourcepub fn atan<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
pub fn atan<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
Builds a node which calculates the arctangent of its input (in radians)
Sourcepub fn exp<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
pub fn exp<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
Builds a node which calculates the exponent of its input
Sourcepub fn ln<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
pub fn ln<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
Builds a node which calculates the natural log of its input
Sourcepub fn square<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
pub fn square<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
Builds a node which squares its input
let x = ctx.x();
let op = ctx.square(x).unwrap();
let v = ctx.eval_xyz(op, 2.0, 0.0, 0.0).unwrap();
assert_eq!(v, 4.0);
Sourcepub fn floor<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
pub fn floor<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
Builds a node which takes the floor of its input
let x = ctx.x();
let op = ctx.floor(x).unwrap();
let v = ctx.eval_xyz(op, 1.2, 0.0, 0.0).unwrap();
assert_eq!(v, 1.0);
Sourcepub fn ceil<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
pub fn ceil<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
Builds a node which takes the ceiling of its input
let x = ctx.x();
let op = ctx.ceil(x).unwrap();
let v = ctx.eval_xyz(op, 1.2, 0.0, 0.0).unwrap();
assert_eq!(v, 2.0);
Sourcepub fn round<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
pub fn round<A: IntoNode>(&mut self, a: A) -> Result<Node, Error>
Builds a node which rounds its input to the nearest integer
let x = ctx.x();
let op = ctx.round(x).unwrap();
let v = ctx.eval_xyz(op, 1.2, 0.0, 0.0).unwrap();
assert_eq!(v, 1.0);
let v = ctx.eval_xyz(op, 1.6, 0.0, 0.0).unwrap();
assert_eq!(v, 2.0);
let v = ctx.eval_xyz(op, 1.5, 0.0, 0.0).unwrap();
assert_eq!(v, 2.0); // rounds away from 0.0 if ambiguous
Sourcepub fn sub<A: IntoNode, B: IntoNode>(
&mut self,
a: A,
b: B,
) -> Result<Node, Error>
pub fn sub<A: IntoNode, B: IntoNode>( &mut self, a: A, b: B, ) -> Result<Node, Error>
Builds a node which performs subtraction.
let x = ctx.x();
let y = ctx.y();
let op = ctx.sub(x, y).unwrap();
let v = ctx.eval_xyz(op, 3.0, 2.0, 0.0).unwrap();
assert_eq!(v, 1.0);
Sourcepub fn div<A: IntoNode, B: IntoNode>(
&mut self,
a: A,
b: B,
) -> Result<Node, Error>
pub fn div<A: IntoNode, B: IntoNode>( &mut self, a: A, b: B, ) -> Result<Node, Error>
Builds a node which performs division.
let x = ctx.x();
let y = ctx.y();
let op = ctx.div(x, y).unwrap();
let v = ctx.eval_xyz(op, 3.0, 2.0, 0.0).unwrap();
assert_eq!(v, 1.5);
Sourcepub fn atan2<A: IntoNode, B: IntoNode>(
&mut self,
y: A,
x: B,
) -> Result<Node, Error>
pub fn atan2<A: IntoNode, B: IntoNode>( &mut self, y: A, x: B, ) -> Result<Node, Error>
Builds a node which computes atan2(y, x)
let x = ctx.x();
let y = ctx.y();
let op = ctx.atan2(y, x).unwrap();
let v = ctx.eval_xyz(op, 0.0, 1.0, 0.0).unwrap();
assert_eq!(v, std::f64::consts::FRAC_PI_2);
Sourcepub fn compare<A: IntoNode, B: IntoNode>(
&mut self,
a: A,
b: B,
) -> Result<Node, Error>
pub fn compare<A: IntoNode, B: IntoNode>( &mut self, a: A, b: B, ) -> Result<Node, Error>
Builds a node that compares two values
The result is -1 if a < b
, +1 if a > b
, 0 if a == b
, and NaN
if
either side is NaN
.
let x = ctx.x();
let op = ctx.compare(x, 1.0).unwrap();
let v = ctx.eval_xyz(op, 0.0, 0.0, 0.0).unwrap();
assert_eq!(v, -1.0);
let v = ctx.eval_xyz(op, 2.0, 0.0, 0.0).unwrap();
assert_eq!(v, 1.0);
let v = ctx.eval_xyz(op, 1.0, 0.0, 0.0).unwrap();
assert_eq!(v, 0.0);
Sourcepub fn less_than<A: IntoNode, B: IntoNode>(
&mut self,
lhs: A,
rhs: B,
) -> Result<Node, Error>
pub fn less_than<A: IntoNode, B: IntoNode>( &mut self, lhs: A, rhs: B, ) -> Result<Node, Error>
Builds a node that is 1 if lhs < rhs
and 0 otherwise
let x = ctx.x();
let y = ctx.y();
let op = ctx.less_than(x, y).unwrap();
let v = ctx.eval_xyz(op, 0.0, 1.0, 0.0).unwrap();
assert_eq!(v, 1.0);
let v = ctx.eval_xyz(op, 1.0, 1.0, 0.0).unwrap();
assert_eq!(v, 0.0);
let v = ctx.eval_xyz(op, 2.0, 1.0, 0.0).unwrap();
assert_eq!(v, 0.0);
Sourcepub fn less_than_or_equal<A: IntoNode, B: IntoNode>(
&mut self,
lhs: A,
rhs: B,
) -> Result<Node, Error>
pub fn less_than_or_equal<A: IntoNode, B: IntoNode>( &mut self, lhs: A, rhs: B, ) -> Result<Node, Error>
Builds a node that is 1 if lhs <= rhs
and 0 otherwise
let x = ctx.x();
let y = ctx.y();
let op = ctx.less_than_or_equal(x, y).unwrap();
let v = ctx.eval_xyz(op, 0.0, 1.0, 0.0).unwrap();
assert_eq!(v, 1.0);
let v = ctx.eval_xyz(op, 1.0, 1.0, 0.0).unwrap();
assert_eq!(v, 1.0);
let v = ctx.eval_xyz(op, 2.0, 1.0, 0.0).unwrap();
assert_eq!(v, 0.0);
Sourcepub fn modulo<A: IntoNode, B: IntoNode>(
&mut self,
a: A,
b: B,
) -> Result<Node, Error>
pub fn modulo<A: IntoNode, B: IntoNode>( &mut self, a: A, b: B, ) -> Result<Node, Error>
Builds a node that takes the modulo (least non-negative remainder)
Sourcepub fn if_nonzero_else<Condition: IntoNode, A: IntoNode, B: IntoNode>(
&mut self,
condition: Condition,
a: A,
b: B,
) -> Result<Node, Error>
pub fn if_nonzero_else<Condition: IntoNode, A: IntoNode, B: IntoNode>( &mut self, condition: Condition, a: A, b: B, ) -> Result<Node, Error>
Builds a node that returns the first node if the condition is not equal to zero, else returns the other node
The result is a
if condition != 0
, else the result is b
.
let x = ctx.x();
let y = ctx.y();
let z = ctx.z();
let if_else = ctx.if_nonzero_else(x, y, z).unwrap();
assert_eq!(ctx.eval_xyz(if_else, 0.0, 2.0, 3.0).unwrap(), 3.0);
assert_eq!(ctx.eval_xyz(if_else, 1.0, 2.0, 3.0).unwrap(), 2.0);
assert_eq!(ctx.eval_xyz(if_else, 0.0, f64::NAN, 3.0).unwrap(), 3.0);
assert_eq!(ctx.eval_xyz(if_else, 1.0, 2.0, f64::NAN).unwrap(), 2.0);
Sourcepub fn eval_xyz(&self, root: Node, x: f64, y: f64, z: f64) -> Result<f64, Error>
pub fn eval_xyz(&self, root: Node, x: f64, y: f64, z: f64) -> Result<f64, Error>
Evaluates the given node with the provided values for X, Y, and Z.
This is extremely inefficient; consider converting the node into a
Shape
and using its evaluators instead.
let x = ctx.x();
let y = ctx.y();
let z = ctx.z();
let op = ctx.mul(x, y).unwrap();
let op = ctx.div(op, z).unwrap();
let v = ctx.eval_xyz(op, 3.0, 5.0, 2.0).unwrap();
assert_eq!(v, 7.5); // (3.0 * 5.0) / 2.0
Sourcepub fn eval(&self, root: Node, vars: &HashMap<Var, f64>) -> Result<f64, Error>
pub fn eval(&self, root: Node, vars: &HashMap<Var, f64>) -> Result<f64, Error>
Evaluates the given node with a generic set of variables
This is extremely inefficient; consider converting the node into a
Shape
and using its evaluators instead.
Sourcepub fn from_text<R: Read>(r: R) -> Result<(Self, Node), Error>
pub fn from_text<R: Read>(r: R) -> Result<(Self, Node), Error>
Parses a flat text representation of a math tree. For example, the
circle (- (+ (square x) (square y)) 1)
can be parsed from
let txt = "
# This is a comment!
0x600000b90000 var-x
0x600000b900a0 square 0x600000b90000
0x600000b90050 var-y
0x600000b900f0 square 0x600000b90050
0x600000b90140 add 0x600000b900a0 0x600000b900f0
0x600000b90190 sqrt 0x600000b90140
0x600000b901e0 const 1
";
let (ctx, _node) = Context::from_text(&mut txt.as_bytes()).unwrap();
assert_eq!(ctx.len(), 7);
This representation is loosely defined and only intended for use in quick experiments.
Sourcepub fn import(&mut self, tree: &Tree) -> Node
pub fn import(&mut self, tree: &Tree) -> Node
Imports the given tree, deduplicating and returning the root
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Context
impl RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnwindSafe for Context
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
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 moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg
or
a color-specific method, such as OwoColorize::green
, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg
or
a color-specific method, such as OwoColorize::on_yellow
, Read moreSource§fn fg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
Source§fn bg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
Source§fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
Source§fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.