Add method to scalar (#283)
This commit is contained in:
parent
4ecf558066
commit
e2212a539a
1 changed files with 14 additions and 0 deletions
|
@ -23,6 +23,13 @@ impl From<String> for ID {
|
|||
}
|
||||
}
|
||||
|
||||
impl ID {
|
||||
/// Construct a new ID from anything implementing `Into<String>`
|
||||
pub fn new<S: Into<String>>(value: S) -> Self {
|
||||
ID(value.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for ID {
|
||||
type Target = str;
|
||||
|
||||
|
@ -353,6 +360,13 @@ mod tests {
|
|||
assert_eq!(actual, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_id_new() {
|
||||
let actual = ID::new("foo");
|
||||
let expected = ID(String::from("foo"));
|
||||
assert_eq!(actual, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_id_deref() {
|
||||
let id = ID(String::from("foo"));
|
||||
|
|
Loading…
Reference in a new issue