Skip to main content

Parameter

Struct Parameter 

Source
pub struct Parameter { /* private fields */ }
Expand description

A symbolic or numeric parameter used to represent gate angles and other continuous values in a quantum circuit.

Parameter is a thin, cheaply-cloneable wrapper around symb_anafis::Expr. It supports the full suite of arithmetic operators (+, -, *, /) between Parameter values as well as between Parameter and primitive numeric types (f64, f32, i32, u32).

The mathematical constants π and e are always available as free symbols and are automatically resolved during Parameter::evaluate.

Implementations§

Source§

impl Parameter

Source

pub fn new(expr: Expr) -> Self

Creates a new Parameter directly from a symb_anafis::Expr node.

Prefer Parameter::symbol for named variables or the From<f64> / From<i32> impls for numeric constants.

Source

pub fn as_expr(&self) -> &Expr

Returns a reference to the underlying expression.

Source

pub fn into_expr(self) -> Expr

Consumes the parameter and returns the underlying expression.

Source

pub fn symbol(name: &str) -> Self

Creates a symbolic parameter representing a free variable with the given name.

§Examples
use cqlib_core::circuit::Parameter;

let theta = Parameter::symbol("θ");
assert_eq!(theta.get_symbols().contains("θ"), true);
Source

pub fn evaluate( &self, bindings: &Option<HashMap<&str, f64>>, ) -> Result<f64, ParameterError>

Evaluates the expression to a concrete f64 value.

The mathematical constants π and e are injected automatically, so callers do not need to supply them. Additional variable bindings are provided through bindings.

Returns ParameterError::NaN if the expression still contains unbound free variables after applying the supplied bindings.

§Examples
use cqlib_core::circuit::Parameter;
use std::collections::HashMap;

// Numeric constant — no bindings needed.
let p = Parameter::from(std::f64::consts::PI);
assert!((p.evaluate(&None).unwrap() - std::f64::consts::PI).abs() < 1e-10);

// Symbolic expression with a user-supplied binding.
let theta = Parameter::symbol("θ");
let expr  = theta * Parameter::from(2.0);
let mut bindings = HashMap::new();
bindings.insert("θ", 1.0_f64);
assert!((expr.evaluate(&Some(bindings)).unwrap() - 2.0).abs() < 1e-10);
Source

pub fn simplify(&self) -> Result<Self, ParameterError>

Returns an algebraically simplified form of this parameter.

Simplification is performed in a domain-safe mode to avoid invalid transformations (e.g. taking the log of a potentially negative number). For affine sums, scalar products and division by numeric constants, nonzero f64 coefficients and cancellation results are preserved without tolerance pruning. Numeric literals are retained exactly. Floating-point rounding, overflow and underflow still apply. Parsing and general nonlinear simplification use the symbolic engine’s own numeric policy.

§Examples
use cqlib_core::circuit::Parameter;

let theta = Parameter::symbol("θ");
let expr  = theta.clone() * Parameter::from(1.0);   // θ * 1
let simplified = expr.simplify().unwrap();
assert_eq!(simplified.to_string(), "θ");
Source

pub fn canonicalized(&self) -> Result<Self, ParameterError>

Returns the canonical storage form of this parameter expression.

A constant expression is evaluated before symbolic simplification. If simplification eliminates all symbols, the result is also evaluated and rebuilt as a finite numeric parameter. This also normalizes -0.0 to 0.0, giving circuit operation storage a stable representation for equivalent constants.

Symbolic expressions are returned in their simplified form. This method does not intern symbolic parameters into any circuit; use Circuit::map_param when a CircuitParam is needed for operation storage.

§Errors

Returns ParameterError if simplification fails, a constant expression cannot be evaluated, or the evaluated constant is not finite.

Source

pub fn is_exact_zero(&self) -> Result<bool, ParameterError>

Returns whether this parameter is exactly the numeric constant 0.0.

This is stricter than Parameter::is_zero: symbolic parameters return false, and constants are compared exactly after evaluation rather than with an epsilon tolerance. Compiler canonicalization uses this predicate when deciding whether a no-op is represented exactly as zero.

§Errors

Returns ParameterError if a constant parameter cannot be evaluated.

Source

pub fn derivative(&self, var: &str) -> Result<Self, ParameterError>

Computes the symbolic partial derivative of this expression with respect to the variable var.

Returns ParameterError if differentiation is not supported for the expression.

§Examples
use cqlib_core::circuit::Parameter;

let theta = Parameter::symbol("θ");
let expr  = theta.clone() * theta.clone();  // θ²
let deriv = expr.derivative("θ").unwrap();  // 2θ
let val   = deriv.evaluate(&Some([("θ", 3.0)].iter().cloned().collect())).unwrap();
assert!((val - 6.0).abs() < 1e-10);
Source

pub fn get_symbols(&self) -> HashSet<String>

Returns the set of free variable names present in this expression.

The built-in constants π and e may appear here if the expression was constructed symbolically (e.g. via Parameter::pi), but they are resolved automatically during Parameter::evaluate.

§Examples
use cqlib_core::circuit::Parameter;

let expr = Parameter::symbol("θ") + Parameter::symbol("φ");
let syms = expr.get_symbols();
assert!(syms.contains("θ"));
assert!(syms.contains("φ"));
Source

pub fn abs(&self) -> Self

Returns a new parameter representing the absolute value |x|.

Source

pub fn sqrt(&self) -> Self

Returns a new parameter representing the square root √x.

Source

pub fn exp(&self) -> Self

Returns a new parameter representing the exponential eˣ.

Source

pub fn sin(&self) -> Self

Returns a new parameter representing the sine sin(x).

Source

pub fn asin(&self) -> Self

Returns a new parameter representing the inverse sine asin(x).

Source

pub fn cos(&self) -> Self

Returns a new parameter representing the cosine cos(x).

Source

pub fn acos(&self) -> Self

Returns a new parameter representing the inverse cosine acos(x).

Source

pub fn tan(&self) -> Self

Returns a new parameter representing the tangent tan(x).

Source

pub fn atan(&self) -> Self

Returns a new parameter representing the inverse tangent atan(x).

Source

pub fn ln(&self) -> Self

Returns a new parameter representing the natural logarithm ln(x).

Source

pub fn log(&self, base: impl Into<Self>) -> Self

Returns a new parameter representing the logarithm log_base(x).

§Examples
use cqlib_core::circuit::Parameter;

// log base 2 of x
let x    = Parameter::symbol("x");
let log2 = x.log(Parameter::from(2.0));
let val  = log2.evaluate(&Some([("x", 8.0)].iter().cloned().collect())).unwrap();
assert!((val - 3.0).abs() < 1e-10);
Source

pub fn pi() -> Self

Returns the mathematical constant π as a symbolic parameter.

The symbol "π" is resolved to std::f64::consts::PI automatically inside Parameter::evaluate.

Source

pub fn e() -> Self

Returns the mathematical constant e (Euler’s number) as a symbolic parameter.

The symbol "e" is resolved to std::f64::consts::E automatically inside Parameter::evaluate.

Source

pub fn pow(&self, exp: impl Into<Self>) -> Self

Returns a new parameter representing self raised to the power exp.

§Examples
use cqlib_core::circuit::Parameter;

let x   = Parameter::symbol("x");
let x3  = x.pow(Parameter::from(3.0));   // x³
let val = x3.evaluate(&Some([("x", 2.0)].iter().cloned().collect())).unwrap();
assert!((val - 8.0).abs() < 1e-10);
Source

pub fn replace(&self, symbol: &str, param: impl Into<Self>) -> Self

Substitutes every occurrence of symbol in this expression with param, returning the resulting expression. The inserted expression is not visited again; the original is unchanged.

§Examples
use cqlib_core::circuit::Parameter;

let expr     = Parameter::symbol("θ") * Parameter::from(2.0);  // θ * 2
let replaced = expr.replace("θ", Parameter::pi());      // π * 2
let val      = replaced.evaluate(&None).unwrap();
assert!((val - 2.0 * std::f64::consts::PI).abs() < 1e-10);
Source

pub fn as_symbol(&self) -> Option<String>

Returns the symbol name if this parameter is exactly one free symbol.

This is intentionally conservative: expressions containing one symbol are accepted only when they are structurally equal to that symbol after optional simplification.

Source

pub fn substitute_many(&self, bindings: &HashMap<String, Parameter>) -> Self

Simultaneously substitutes bound symbols and simplifies when possible.

Replacement expressions are inserted as-is, without applying other bindings to them. The result is independent of binding iteration order, and the original expression is unchanged.

Source

pub fn provably_equal(&self, other: &Self, tolerance: f64) -> bool

Returns whether two parameters are provably equal within tolerance.

This is a conservative symbolic check. It accepts structural equality after simplification and concrete numeric equality, but it does not try to prove arbitrary symbolic identities.

Source

pub fn provably_equal_modulo( &self, other: &Self, modulus: &Self, tolerance: f64, ) -> bool

Returns whether two parameters are provably equal modulo modulus.

Fully numeric parameters take a fast path with plain floating-point math, without building or simplifying a symbolic difference expression. Only expressions with unbound symbols fall back to the symbolic path, where the expression difference and modulus must both evaluate without extra bindings for the numeric modulo check to apply.

Source

pub fn is_constant(&self) -> bool

Returns true if this parameter is a constant (has no free variables).

§Examples
use cqlib_core::circuit::Parameter;

let constant = Parameter::from(3.14);
assert!(constant.is_constant());

let symbolic = Parameter::symbol("x");
assert!(!symbolic.is_constant());
Source

pub fn is_zero(&self) -> bool

Returns true if this parameter evaluates to zero.

Returns false if the parameter cannot be evaluated (contains unbound symbols).

§Examples
use cqlib_core::circuit::Parameter;

let zero = Parameter::from(0.0);
assert!(zero.is_zero());

let non_zero = Parameter::from(1.0);
assert!(!non_zero.is_zero());
Source

pub fn is_one(&self) -> bool

Returns true if this parameter evaluates to one.

Returns false if the parameter cannot be evaluated (contains unbound symbols).

§Examples
use cqlib_core::circuit::Parameter;

let one = Parameter::from(1.0);
assert!(one.is_one());

let non_one = Parameter::from(2.0);
assert!(!non_one.is_one());
Source

pub fn sinh(&self) -> Self

Returns the hyperbolic sine sinh(x).

Source

pub fn cosh(&self) -> Self

Returns the hyperbolic cosine cosh(x).

Source

pub fn tanh(&self) -> Self

Returns the hyperbolic tangent tanh(x).

Source

pub fn floor(&self) -> Self

Returns the floor of the expression.

Source

pub fn ceil(&self) -> Self

Returns the ceiling of the expression.

Source

pub fn round(&self) -> Self

Returns the rounded value of the expression.

Trait Implementations§

Source§

impl Add for Parameter

Source§

type Output = Parameter

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Parameter) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a> Add<&'a Parameter> for Parameter

Source§

type Output = Parameter

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &'a Parameter) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a, 'b> Add<&'b Parameter> for &'a Parameter

Source§

type Output = Parameter

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &'b Parameter) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<Parameter> for f64

Source§

type Output = Parameter

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Parameter) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<Parameter> for f32

Source§

type Output = Parameter

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Parameter) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<Parameter> for i32

Source§

type Output = Parameter

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Parameter) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<Parameter> for u32

Source§

type Output = Parameter

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Parameter) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a> Add<Parameter> for &'a Parameter

Source§

type Output = Parameter

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Parameter) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<f32> for Parameter

Source§

type Output = Parameter

The resulting type after applying the + operator.
Source§

fn add(self, rhs: f32) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<f64> for Parameter

Source§

type Output = Parameter

The resulting type after applying the + operator.
Source§

fn add(self, rhs: f64) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<i32> for Parameter

Source§

type Output = Parameter

The resulting type after applying the + operator.
Source§

fn add(self, rhs: i32) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<u32> for Parameter

Source§

type Output = Parameter

The resulting type after applying the + operator.
Source§

fn add(self, rhs: u32) -> Self::Output

Performs the + operation. Read more
Source§

impl Clone for Parameter

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Parameter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Parameter

Source§

fn default() -> Self

Creates a default parameter representing the integer 0.

Source§

impl Display for Parameter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the parameter as a human-readable mathematical string.

Source§

impl Div for Parameter

Source§

type Output = Parameter

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Parameter) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a> Div<&'a Parameter> for Parameter

Source§

type Output = Parameter

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &'a Parameter) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a, 'b> Div<&'b Parameter> for &'a Parameter

Source§

type Output = Parameter

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &'b Parameter) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Parameter> for f64

Source§

type Output = Parameter

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Parameter) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Parameter> for f32

Source§

type Output = Parameter

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Parameter) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Parameter> for i32

Source§

type Output = Parameter

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Parameter) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Parameter> for u32

Source§

type Output = Parameter

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Parameter) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a> Div<Parameter> for &'a Parameter

Source§

type Output = Parameter

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Parameter) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<f32> for Parameter

Source§

type Output = Parameter

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f32) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<f64> for Parameter

Source§

type Output = Parameter

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f64) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<i32> for Parameter

Source§

type Output = Parameter

The resulting type after applying the / operator.
Source§

fn div(self, rhs: i32) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<u32> for Parameter

Source§

type Output = Parameter

The resulting type after applying the / operator.
Source§

fn div(self, rhs: u32) -> Self::Output

Performs the / operation. Read more
Source§

impl Eq for Parameter

Source§

impl From<&Parameter> for ParameterValue

Source§

fn from(para: &Parameter) -> Self

Converts to this type from the input type.
Source§

impl From<&ParameterValue> for Parameter

Source§

fn from(para: &ParameterValue) -> Parameter

Converts to this type from the input type.
Source§

impl From<Expr> for Parameter

Source§

fn from(expr: Expr) -> Self

Converts to this type from the input type.
Source§

impl From<Parameter> for ParameterValue

Source§

fn from(para: Parameter) -> Self

Converts a Parameter into a ParameterValue.

It attempts to eagerly evaluate the parameter if it represents a known constant (like Pi, E, or a simple number) to optimize storage.

Source§

impl From<Parameter> for Expr

Source§

fn from(p: Parameter) -> Self

Converts to this type from the input type.
Source§

impl From<ParameterValue> for Parameter

Source§

fn from(para: ParameterValue) -> Parameter

Converts to this type from the input type.
Source§

impl From<f32> for Parameter

Source§

fn from(value: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Parameter

Source§

fn from(value: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Parameter

Source§

fn from(value: i32) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Parameter

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Parameter

Source§

fn from_str(expr: &str) -> Result<Self, Self::Err>

Parses a symbolic expression from a string.

Returns ParameterError::ParseError if the string cannot be parsed as a valid expression.

§Examples
use cqlib_core::circuit::Parameter;
use std::str::FromStr;

let p = Parameter::from_str("θ * 2 + π").unwrap();
let bad = Parameter::from_str("@@@");
assert!(bad.is_err());
Source§

type Err = ParameterError

The associated error which can be returned from parsing.
Source§

impl Hash for Parameter

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Mul for Parameter

Source§

type Output = Parameter

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Parameter) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a> Mul<&'a Parameter> for Parameter

Source§

type Output = Parameter

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'a Parameter) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a, 'b> Mul<&'b Parameter> for &'a Parameter

Source§

type Output = Parameter

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b Parameter) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Parameter> for f64

Source§

type Output = Parameter

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Parameter) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Parameter> for f32

Source§

type Output = Parameter

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Parameter) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Parameter> for i32

Source§

type Output = Parameter

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Parameter) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Parameter> for u32

Source§

type Output = Parameter

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Parameter) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a> Mul<Parameter> for &'a Parameter

Source§

type Output = Parameter

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Parameter) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<f32> for Parameter

Source§

type Output = Parameter

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f32) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<f64> for Parameter

Source§

type Output = Parameter

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f64) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<i32> for Parameter

Source§

type Output = Parameter

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: i32) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<u32> for Parameter

Source§

type Output = Parameter

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: u32) -> Self::Output

Performs the * operation. Read more
Source§

impl Neg for Parameter

Source§

type Output = Parameter

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl Neg for &Parameter

Source§

type Output = Parameter

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl PartialEq for Parameter

Source§

fn eq(&self, other: &Self) -> bool

Checks equality based on the underlying expression structure.

Note: This performs structural equality of the AST, not semantic mathematical equality. For example, x + y and y + x are structurally different and will compare as unequal.

1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Sub for Parameter

Source§

type Output = Parameter

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Parameter) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a> Sub<&'a Parameter> for Parameter

Source§

type Output = Parameter

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &'a Parameter) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a, 'b> Sub<&'b Parameter> for &'a Parameter

Source§

type Output = Parameter

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &'b Parameter) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<Parameter> for f64

Source§

type Output = Parameter

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Parameter) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<Parameter> for f32

Source§

type Output = Parameter

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Parameter) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<Parameter> for i32

Source§

type Output = Parameter

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Parameter) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<Parameter> for u32

Source§

type Output = Parameter

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Parameter) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a> Sub<Parameter> for &'a Parameter

Source§

type Output = Parameter

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Parameter) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<f32> for Parameter

Source§

type Output = Parameter

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: f32) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<f64> for Parameter

Source§

type Output = Parameter

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: f64) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<i32> for Parameter

Source§

type Output = Parameter

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: i32) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<u32> for Parameter

Source§

type Output = Parameter

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: u32) -> Self::Output

Performs the - operation. Read more
Source§

impl TryFrom<&str> for Parameter

Source§

fn try_from(expr: &str) -> Result<Self, Self::Error>

Parses a symbolic expression from a string slice.

Returns ParameterError::ParseError if the string cannot be parsed as a valid expression.

§Examples
use cqlib_core::circuit::Parameter;

let p = Parameter::try_from("θ * 2 + π").unwrap();
let bad = Parameter::try_from("@@@");
assert!(bad.is_err());
Source§

type Error = ParameterError

The type returned in the event of a conversion error.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<Rhs, Lhs, Output> AddByRef<Rhs> for Lhs
where &'a Lhs: for<'a> Add<&'a Rhs, Output = Output>,

Source§

type Output = Output

Source§

fn add_by_ref(&self, rhs: &Rhs) -> <Lhs as AddByRef<Rhs>>::Output

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<T> CallHasher for T
where T: Hash + ?Sized,

Source§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64
where H: Hash + ?Sized, B: BuildHasher,

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> DistributionExt for T
where T: ?Sized,

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<Rhs, Lhs, Output> DivByRef<Rhs> for Lhs
where &'a Lhs: for<'a> Div<&'a Rhs, Output = Output>,

Source§

type Output = Output

Source§

fn div_by_ref(&self, rhs: &Rhs) -> <Lhs as DivByRef<Rhs>>::Output

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> Fmt for T
where T: Display,

Source§

fn fg<C>(self, color: C) -> Foreground<Self>
where C: Into<Option<Color>>, Self: Display,

Give this value the specified foreground colour.
Source§

fn bg<C>(self, color: C) -> Background<Self>
where C: Into<Option<Color>>, Self: Display,

Give this value the specified background colour.
Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<Rhs, Lhs, Output> MulByRef<Rhs> for Lhs
where &'a Lhs: for<'a> Mul<&'a Rhs, Output = Output>,

Source§

type Output = Output

Source§

fn mul_by_ref(&self, rhs: &Rhs) -> <Lhs as MulByRef<Rhs>>::Output

Source§

impl<T, Output> NegByRef for T
where &'a T: for<'a> Neg<Output = Output>,

Source§

type Output = Output

Source§

fn neg_by_ref(&self) -> <T as NegByRef>::Output

Source§

impl<T> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> StdoutFmt for T
where T: Display,

Source§

fn fg<C>(self, color: C) -> Foreground<Self>
where C: Into<Option<Color>>,

Give this value the specified foreground colour, when color is enabled for stdout.
Source§

fn bg<C>(self, color: C) -> Background<Self>
where C: Into<Option<Color>>,

Give this value the specified background colour, when color is enabled for stdout.
Source§

impl<Rhs, Lhs, Output> SubByRef<Rhs> for Lhs
where &'a Lhs: for<'a> Sub<&'a Rhs, Output = Output>,

Source§

type Output = Output

Source§

fn sub_by_ref(&self, rhs: &Rhs) -> <Lhs as SubByRef<Rhs>>::Output

Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V