Skip to content

Commit 9392541

Browse files
committed
Clarify type_complexity
1 parent a53614a commit 9392541

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

clippy_lints/src/types/mod.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,57 @@ declare_clippy_lint! {
264264
/// struct Foo {
265265
/// inner: Rc<Vec<Vec<Box<(u32, u32, u32, u32)>>>>,
266266
/// }
267+
///
268+
/// fn main() {
269+
/// let inner_data: Vec<Vec<Box<(u32, u32, u32, u32)>>> = vec![
270+
/// vec![
271+
/// Box::new((1, 2, 3, 4)),
272+
/// Box::new((5, 6, 7, 8)),
273+
/// ],
274+
/// vec![
275+
/// Box::new((9, 10, 11, 12)),
276+
/// ],
277+
/// ];
278+
///
279+
/// let rc_inner_data: Rc<Vec<Vec<Box<(u32, u32, u32, u32)>>>> = Rc::new(inner_data);
280+
///
281+
/// let foo = Foo {
282+
/// inner: rc_inner_data,
283+
/// };
284+
///
285+
/// // ...
286+
/// }
287+
/// ```
288+
/// Use instead:
289+
/// ### Example
290+
/// ```no_run
291+
/// # use std::rc::Rc;
292+
/// type InnerType = Vec<Vec<Box<(u32, u32, u32, u32)>>>;
293+
/// type RcInnerType = Rc<InnerType>;
294+
///
295+
/// struct Foo {
296+
/// inner: RcInnerType,
297+
/// }
298+
///
299+
/// fn main() {
300+
/// let inner_data: InnerType = vec![
301+
/// vec![
302+
/// Box::new((1, 2, 3, 4)),
303+
/// Box::new((5, 6, 7, 8)),
304+
/// ],
305+
/// vec![
306+
/// Box::new((9, 10, 11, 12)),
307+
/// ],
308+
/// ];
309+
///
310+
/// let rc_inner_data: RcInnerType = Rc::new(inner_data);
311+
///
312+
/// let foo = Foo {
313+
/// inner: rc_inner_data,
314+
/// };
315+
///
316+
/// // ...
317+
/// }
267318
/// ```
268319
#[clippy::version = "pre 1.29.0"]
269320
pub TYPE_COMPLEXITY,

0 commit comments

Comments
 (0)