Scope::set_value takes name that implements Into<Cow<str>>.
This commit is contained in:
parent
b915433b00
commit
c1b4c81e75
10
src/scope.rs
10
src/scope.rs
@ -362,12 +362,16 @@ impl<'a> Scope<'a> {
|
||||
/// assert_eq!(my_scope.get_value::<i64>("x").unwrap(), 0);
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn set_value(&mut self, name: &'a str, value: impl Variant + Clone) -> &mut Self {
|
||||
match self.get_index(name) {
|
||||
pub fn set_value(
|
||||
&mut self,
|
||||
name: impl AsRef<str> + Into<Cow<'a, str>>,
|
||||
value: impl Variant + Clone,
|
||||
) -> &mut Self {
|
||||
match self.get_index(name.as_ref()) {
|
||||
None => {
|
||||
self.push(name, value);
|
||||
}
|
||||
Some((_, AccessMode::ReadOnly)) => panic!("variable {} is constant", name),
|
||||
Some((_, AccessMode::ReadOnly)) => panic!("variable {} is constant", name.as_ref()),
|
||||
Some((index, AccessMode::ReadWrite)) => {
|
||||
let value_ref = self
|
||||
.values
|
||||
|
Loading…
Reference in New Issue
Block a user