Use idiomatic map_or_else
calls to Option<T> instead of double returns
Signed-off-by: Victor Porof <vporof@mozilla.com>
This commit is contained in:
parent
85da91a0ab
commit
8f68f68378
1 changed files with 7 additions and 9 deletions
|
@ -217,15 +217,13 @@ fn to_ord(value: &Value) -> i32 {
|
||||||
pub struct Pair(Value, Value);
|
pub struct Pair(Value, Value);
|
||||||
|
|
||||||
pub fn to_symbol<'a, T: Into<Option<&'a str>>>(namespace: T, name: &str) -> Value {
|
pub fn to_symbol<'a, T: Into<Option<&'a str>>>(namespace: T, name: &str) -> Value {
|
||||||
if let Some(ns) = namespace.into() {
|
namespace.into().map_or_else(
|
||||||
return Value::NamespacedSymbol(symbols::NamespacedSymbol::new(ns, name));
|
|| Value::PlainSymbol(symbols::PlainSymbol::new(name)),
|
||||||
}
|
|ns| Value::NamespacedSymbol(symbols::NamespacedSymbol::new(ns, name)))
|
||||||
return Value::PlainSymbol(symbols::PlainSymbol::new(name));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_keyword<'a, T: Into<Option<&'a str>>>(namespace: T, name: &str) -> Value {
|
pub fn to_keyword<'a, T: Into<Option<&'a str>>>(namespace: T, name: &str) -> Value {
|
||||||
if let Some(ns) = namespace.into() {
|
namespace.into().map_or_else(
|
||||||
return Value::NamespacedKeyword(symbols::NamespacedKeyword::new(ns, name));
|
|| Value::Keyword(symbols::Keyword::new(name)),
|
||||||
}
|
|ns| Value::NamespacedKeyword(symbols::NamespacedKeyword::new(ns, name)))
|
||||||
return Value::Keyword(symbols::Keyword::new(name));
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue