Remove implicit cloning for string values

This commit is contained in:
Jeff 2024-03-08 16:22:24 -05:00
parent 56fbbdee0b
commit 0c1a2f4499
3 changed files with 7 additions and 7 deletions

View File

@ -75,7 +75,7 @@ mod tests {
None
)
.run(&Context::new()),
Ok(Action::Return(Value::string("foo")))
Ok(Action::Return(Value::string("foo".to_string())))
)
}
@ -90,7 +90,7 @@ mod tests {
))))
)
.run(&Context::new()),
Ok(Action::Return(Value::string("bar")))
Ok(Action::Return(Value::string("bar".to_string())))
)
}
}

View File

@ -64,8 +64,8 @@ impl Value {
Value(Arc::new(ValueInner::Range(range)))
}
pub fn string<T: ToString>(string: T) -> Self {
Value(Arc::new(ValueInner::String(string.to_string())))
pub fn string(string: String) -> Self {
Value(Arc::new(ValueInner::String(string)))
}
pub fn r#enum(name: Identifier, variant: Identifier) -> Self {

View File

@ -15,7 +15,7 @@ fn loops_and_breaks() {
}
"
),
Ok(Some(Value::string("foobar")))
Ok(Some(Value::string("foobar".to_string())))
)
}
@ -23,7 +23,7 @@ fn loops_and_breaks() {
fn r#if() {
assert_eq!(
interpret("if true 'foobar'"),
Ok(Some(Value::string("foobar")))
Ok(Some(Value::string("foobar".to_string())))
)
}
@ -31,6 +31,6 @@ fn r#if() {
fn if_else() {
assert_eq!(
interpret("if false 'foo' else 'bar'"),
Ok(Some(Value::string("bar")))
Ok(Some(Value::string("bar".to_string())))
)
}