diff options
Diffstat (limited to '')
-rw-r--r-- | src/tools/clippy/src/docs/option_option.txt | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/src/tools/clippy/src/docs/option_option.txt b/src/tools/clippy/src/docs/option_option.txt deleted file mode 100644 index b4324bd83..000000000 --- a/src/tools/clippy/src/docs/option_option.txt +++ /dev/null @@ -1,32 +0,0 @@ -### What it does -Checks for use of `Option<Option<_>>` in function signatures and type -definitions - -### Why is this bad? -`Option<_>` represents an optional value. `Option<Option<_>>` -represents an optional optional value which is logically the same thing as an optional -value but has an unneeded extra level of wrapping. - -If you have a case where `Some(Some(_))`, `Some(None)` and `None` are distinct cases, -consider a custom `enum` instead, with clear names for each case. - -### Example -``` -fn get_data() -> Option<Option<u32>> { - None -} -``` - -Better: - -``` -pub enum Contents { - Data(Vec<u8>), // Was Some(Some(Vec<u8>)) - NotYetFetched, // Was Some(None) - None, // Was None -} - -fn get_data() -> Contents { - Contents::None -} -```
\ No newline at end of file |