1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
14 #[warn(clippy::cmp_owned)]
15 #[allow(clippy::unnecessary_operation)]
17 fn with_to_string(x : &str) {
18 x != "foo".to_string();
20 "foo".to_string() != x;
27 x != "foo".to_owned();
29 x != String::from("foo");
31 42.to_string() == "42";
33 Foo.to_owned() == Foo;
35 "abc".chars().filter(|c| c.to_owned() != 'X');
37 "abc".chars().filter(|c| *c != 'X');
52 impl PartialEq for Foo {
53 fn eq(&self, other: &Self) -> bool {
54 self.to_owned() == *other
58 impl ToOwned for Foo {
60 fn to_owned(&self) -> Bar {
68 impl PartialEq<Foo> for Bar {
69 fn eq(&self, _: &Foo) -> bool {
74 impl std::borrow::Borrow<Foo> for Bar {
75 fn borrow(&self) -> &Foo {
76 static FOO: Foo = Foo;
84 impl ToOwned for Baz {
86 fn to_owned(&self) -> Baz {