File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -99,14 +99,32 @@ declare_clippy_lint! {
9999 /// represents an optional optional value which is logically the same thing as an optional
100100 /// value but has an unneeded extra level of wrapping.
101101 ///
102+ /// If you have a case where `Some(Some(_))`, `Some(None)` and `None` are distinct cases,
103+ /// consider a custom `enum` instead, with clear names for each case.
104+ ///
102105 /// **Known problems:** None.
103106 ///
104107 /// **Example**
105- /// ```rust
106- /// fn x( ) -> Option<Option<u32>> {
108+ /// ```rust,ignore
109+ /// fn get_node_data(n: Node ) -> Option<Option<u32>> {
107110 /// None
108111 /// }
109112 /// ```
113+ ///
114+ /// Better:
115+ ///
116+ /// ```rust,ignore
117+ /// pub enum Contents {
118+ /// Data(Vec<u8>), // Was Some(Some(Vec<u8>))
119+ /// NotYetFetched, // Was Some(None)
120+ /// None, // Was None
121+ /// }
122+ ///
123+ /// fn get_node_data(n: Node) -> Contents {
124+ /// Contents::None
125+ /// }
126+ /// ```
127+ ///
110128 pub OPTION_OPTION ,
111129 pedantic,
112130 "usage of `Option<Option<T>>`"
You can’t perform that action at this time.
0 commit comments