pub struct ParametersStore { /* private fields */ }Expand description
A store that maps parameters to their assigned names.
ParametersStore maintains a registry of parameters and their
human-readable names, which is useful for displaying and debugging
expression parameters. The store allows for consistent name resolution of
parameters used in expressions.
§Examples
use bc_envelope::{
extension::expressions::{ParametersStore, parameters},
prelude::*,
};
// Create a store with common parameters
let store = ParametersStore::new([
parameters::LHS,
parameters::RHS,
parameters::BLANK,
]);
// Look up the name of a parameter
assert_eq!(store.name(¶meters::LHS), "lhs");Implementations§
Source§impl ParametersStore
impl ParametersStore
Sourcepub fn new<T>(parameters: T) -> Selfwhere
T: IntoIterator<Item = Parameter>,
pub fn new<T>(parameters: T) -> Selfwhere
T: IntoIterator<Item = Parameter>,
Creates a new ParametersStore with the given parameters.
§Parameters
parameters- An iterable ofParameterinstances to store
§Returns
A new ParametersStore containing the parameters
§Examples
use bc_envelope::{
extension::expressions::{ParametersStore, parameters},
prelude::*,
};
// Create a store with standard parameters
let store = ParametersStore::new([
parameters::LHS,
parameters::RHS,
parameters::BLANK,
]);Sourcepub fn insert(&mut self, parameter: Parameter)
pub fn insert(&mut self, parameter: Parameter)
Inserts a parameter into the store.
§Parameters
parameter- The parameter to insert
§Examples
use bc_envelope::{
extension::expressions::{Parameter, ParametersStore, parameters},
prelude::*,
};
let mut store = ParametersStore::default();
store.insert(parameters::LHS);
store.insert(Parameter::new_with_static_name(100, "myCustomParameter"));Sourcepub fn assigned_name(&self, parameter: &Parameter) -> Option<&str>
pub fn assigned_name(&self, parameter: &Parameter) -> Option<&str>
Returns the assigned name for a parameter, if it exists in the store.
§Parameters
parameter- The parameter to look up
§Returns
Some string slice with the parameter name if found, or None if not found
§Examples
use bc_envelope::{
extension::expressions::{ParametersStore, parameters},
prelude::*,
};
let store = ParametersStore::new([parameters::LHS]);
assert_eq!(store.assigned_name(¶meters::LHS), Some("lhs"));
assert_eq!(store.assigned_name(¶meters::RHS), None);Sourcepub fn name(&self, parameter: &Parameter) -> String
pub fn name(&self, parameter: &Parameter) -> String
Returns the name for a parameter, either from this store or from the parameter itself.
If the parameter exists in the store, returns its assigned name. Otherwise, returns the parameter’s own name.
§Parameters
parameter- The parameter to look up
§Returns
The name of the parameter as a String
§Examples
use bc_envelope::{
extension::expressions::{ParametersStore, parameters},
prelude::*,
};
let store = ParametersStore::new([parameters::LHS]);
assert_eq!(store.name(¶meters::LHS), "lhs");
// Not in store, so uses parameter's own name
assert_eq!(store.name(¶meters::RHS), "rhs");Sourcepub fn name_for_parameter(
parameter: &Parameter,
parameters: Option<&Self>,
) -> String
pub fn name_for_parameter( parameter: &Parameter, parameters: Option<&Self>, ) -> String
A static method that returns the name of a parameter, using an optional store.
This utility method is useful when you have an optional store and want to get a parameter name without additional unwrapping logic.
§Parameters
parameter- The parameter to look upparameters- An optional reference to a ParametersStore
§Returns
The name of the parameter as a String
§Examples
use bc_envelope::{
extension::expressions::{ParametersStore, parameters},
prelude::*,
};
let store = ParametersStore::new([parameters::LHS]);
// Using the store
assert_eq!(
ParametersStore::name_for_parameter(¶meters::LHS, Some(&store)),
"lhs"
);
// Without a store
assert_eq!(
ParametersStore::name_for_parameter(¶meters::LHS, None),
"lhs"
);Trait Implementations§
Source§impl Clone for ParametersStore
impl Clone for ParametersStore
Source§fn clone(&self) -> ParametersStore
fn clone(&self) -> ParametersStore
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ParametersStore
impl Debug for ParametersStore
Auto Trait Implementations§
impl Freeze for ParametersStore
impl RefUnwindSafe for ParametersStore
impl Send for ParametersStore
impl Sync for ParametersStore
impl Unpin for ParametersStore
impl UnwindSafe for ParametersStore
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
§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)
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>
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