Add Into<String> to symbol::* constructors. Fixes #199
This commit is contained in:
parent
c6fa14c0c8
commit
18279fdd3c
1 changed files with 14 additions and 9 deletions
|
@ -80,11 +80,14 @@ impl PlainSymbol {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NamespacedSymbol {
|
impl NamespacedSymbol {
|
||||||
pub fn new(namespace: &str, name: &str) -> Self {
|
pub fn new<T>(namespace: T, name: T) -> Self where T: Into<String> {
|
||||||
assert!(!name.is_empty(), "Symbols cannot be unnamed.");
|
let n = name.into();
|
||||||
assert!(!namespace.is_empty(), "Symbols cannot have an empty non-null namespace.");
|
let ns = namespace.into();
|
||||||
|
|
||||||
NamespacedSymbol { name: name.to_string(), namespace: namespace.to_string() }
|
assert!(!n.is_empty(), "Symbols cannot be unnamed.");
|
||||||
|
assert!(!ns.is_empty(), "Symbols cannot have an empty non-null namespace.");
|
||||||
|
|
||||||
|
NamespacedSymbol { name: n, namespace: ns }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,12 +101,14 @@ impl Keyword {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NamespacedKeyword {
|
impl NamespacedKeyword {
|
||||||
pub fn new(namespace: &str, name: &str) -> Self {
|
pub fn new<T>(namespace: T, name: T) -> Self where T: Into<String> {
|
||||||
assert!(!name.is_empty(), "Keywords cannot be unnamed.");
|
let n = name.into();
|
||||||
assert!(!namespace.is_empty(), "Keywords cannot have an empty non-null namespace.");
|
let ns = namespace.into();
|
||||||
|
assert!(!n.is_empty(), "Keywords cannot be unnamed.");
|
||||||
|
assert!(!ns.is_empty(), "Keywords cannot have an empty non-null namespace.");
|
||||||
|
|
||||||
// TODO: debug asserts to ensure that neither field matches [ :/].
|
// TODO: debug asserts to ensure that neither field matches [ :/].
|
||||||
NamespacedKeyword { name: name.to_string(), namespace: namespace.to_string() }
|
NamespacedKeyword { name: n, namespace: ns }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue