We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent baab352 commit 20e73f3Copy full SHA for 20e73f3
src/atom/mod.rs
@@ -11,6 +11,7 @@
11
12
use phf::OrderedSet;
13
14
+use std::borrow::Borrow;
15
use std::fmt;
16
use std::mem;
17
use std::ops;
@@ -303,6 +304,13 @@ impl Ord for Atom {
303
304
}
305
306
307
+impl Borrow<str> for Atom {
308
+ fn borrow(&self) -> &str {
309
+ &self
310
+ }
311
+}
312
+
313
314
#[cfg(test)]
315
mod bench;
316
@@ -522,4 +530,12 @@ mod tests {
522
530
let atom = Atom::from_slice("foobar");
523
531
let _: &str = &atom;
524
532
533
534
+ #[test]
535
+ fn ensure_borrow() {
536
+ // Ensure std::borrow::Borrow is implemented
537
+ let atoms = vec![Atom::from_slice("foo"), Atom::from_slice("bar")];
538
+ let joined_atoms = atoms.connect(" ");
539
+ assert_eq!(joined_atoms, "foo bar");
540
525
541
0 commit comments