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);
|
/// assert_eq!(my_scope.get_value::<i64>("x").unwrap(), 0);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_value(&mut self, name: &'a str, value: impl Variant + Clone) -> &mut Self {
|
pub fn set_value(
|
||||||
match self.get_index(name) {
|
&mut self,
|
||||||
|
name: impl AsRef<str> + Into<Cow<'a, str>>,
|
||||||
|
value: impl Variant + Clone,
|
||||||
|
) -> &mut Self {
|
||||||
|
match self.get_index(name.as_ref()) {
|
||||||
None => {
|
None => {
|
||||||
self.push(name, value);
|
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)) => {
|
Some((index, AccessMode::ReadWrite)) => {
|
||||||
let value_ref = self
|
let value_ref = self
|
||||||
.values
|
.values
|
||||||
|
Loading…
Reference in New Issue
Block a user