Skip to content

Commit 307252e

Browse files
committed
Added example to show the AsRef working
1 parent bb2ca25 commit 307252e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

exercises/conversions/as_ref_mut.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,16 @@ mod tests {
3636
let s = "Cafe au lait";
3737
assert_eq!(char_counter(s), byte_counter(s));
3838
}
39+
40+
#[test]
41+
fn different_counts_using_string() {
42+
let s = String::from("Café au lait");
43+
assert_ne!(char_counter(s.clone()), byte_counter(s));
44+
}
45+
46+
#[test]
47+
fn same_counts_using_string() {
48+
let s = String::from("Cafe au lait");
49+
assert_eq!(char_counter(s.clone()), byte_counter(s));
50+
}
3951
}

0 commit comments

Comments
 (0)