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.
10 #[warn(clippy::cmp_owned)]
11 #[allow(clippy::unnecessary_operation)]
13 fn with_to_string(x: &str) {
14 x != "foo".to_string();
16 "foo".to_string() != x;
23 x != "foo".to_owned();
25 x != String::from("foo");
27 42.to_string() == "42";
29 Foo.to_owned() == Foo;
31 "abc".chars().filter(|c| c.to_owned() != 'X');
33 "abc".chars().filter(|c| *c != 'X');
48 impl PartialEq for Foo {
49 fn eq(&self, other: &Self) -> bool {
50 self.to_owned() == *other
54 impl ToOwned for Foo {
56 fn to_owned(&self) -> Bar {
64 impl PartialEq<Foo> for Bar {
65 fn eq(&self, _: &Foo) -> bool {
70 impl std::borrow::Borrow<Foo> for Bar {
71 fn borrow(&self) -> &Foo {
72 static FOO: Foo = Foo;
80 impl ToOwned for Baz {
82 fn to_owned(&self) -> Baz {