diff options
Diffstat (limited to 'src/tools/clippy/src/docs/new_ret_no_self.txt')
-rw-r--r-- | src/tools/clippy/src/docs/new_ret_no_self.txt | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/src/tools/clippy/src/docs/new_ret_no_self.txt b/src/tools/clippy/src/docs/new_ret_no_self.txt deleted file mode 100644 index 291bad24a..000000000 --- a/src/tools/clippy/src/docs/new_ret_no_self.txt +++ /dev/null @@ -1,47 +0,0 @@ -### What it does -Checks for `new` not returning a type that contains `Self`. - -### Why is this bad? -As a convention, `new` methods are used to make a new -instance of a type. - -### Example -In an impl block: -``` -impl Foo { - fn new() -> NotAFoo { - } -} -``` - -``` -struct Bar(Foo); -impl Foo { - // Bad. The type name must contain `Self` - fn new() -> Bar { - } -} -``` - -``` -impl Foo { - // Good. Return type contains `Self` - fn new() -> Result<Foo, FooError> { - } -} -``` - -Or in a trait definition: -``` -pub trait Trait { - // Bad. The type name must contain `Self` - fn new(); -} -``` - -``` -pub trait Trait { - // Good. Return type contains `Self` - fn new() -> Self; -} -```
\ No newline at end of file |