2 Checks for the usage of `_.to_owned()`, on a `Cow<'_, _>`.
5 Calling `to_owned()` on a `Cow` creates a clone of the `Cow`
6 itself, without taking ownership of the `Cow` contents (i.e.
7 it's equivalent to calling `Cow::clone`).
8 The similarly named `into_owned` method, on the other hand,
9 clones the `Cow` contents, effectively turning any `Cow::Borrowed`
12 Given the potential ambiguity, consider replacing `to_owned`
13 with `clone` for better readability or, if getting a `Cow::Owned`
14 was the original intent, using `into_owned` instead.
18 let s = "Hello world!";
19 let cow = Cow::Borrowed(s);
21 let data = cow.to_owned();
22 assert!(matches!(data, Cow::Borrowed(_)))
26 let s = "Hello world!";
27 let cow = Cow::Borrowed(s);
29 let data = cow.clone();
30 assert!(matches!(data, Cow::Borrowed(_)))
34 let s = "Hello world!";
35 let cow = Cow::Borrowed(s);
37 let data = cow.into_owned();
38 assert!(matches!(data, String))