Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 2c5e600

Browse files
committed
Auto merge of rust-lang#13392 - alex-semenyuk:doc_type_complexity, r=dswij
Clarify example for `type_complexity` As mentioned rust-lang#13387 it's not clear how to fix issue with complexity so add example for this changelog: none
2 parents 0e1ded0 + bc7d323 commit 2c5e600

File tree

1 file changed

+53
-2
lines changed

1 file changed

+53
-2
lines changed

clippy_lints/src/types/mod.rs

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,59 @@ declare_clippy_lint! {
261261
/// ### Example
262262
/// ```no_run
263263
/// # use std::rc::Rc;
264-
/// struct Foo {
265-
/// inner: Rc<Vec<Vec<Box<(u32, u32, u32, u32)>>>>,
264+
/// struct PointMatrixContainer {
265+
/// matrix: Rc<Vec<Vec<Box<(u32, u32, u32, u32)>>>>,
266+
/// }
267+
///
268+
/// fn main() {
269+
/// let point_matrix: 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 shared_point_matrix: Rc<Vec<Vec<Box<(u32, u32, u32, u32)>>>> = Rc::new(point_matrix);
280+
///
281+
/// let container = PointMatrixContainer {
282+
/// matrix: shared_point_matrix,
283+
/// };
284+
///
285+
/// // ...
286+
/// }
287+
/// ```
288+
/// Use instead:
289+
/// ### Example
290+
/// ```no_run
291+
/// # use std::rc::Rc;
292+
/// type PointMatrix = Vec<Vec<Box<(u32, u32, u32, u32)>>>;
293+
/// type SharedPointMatrix = Rc<PointMatrix>;
294+
///
295+
/// struct PointMatrixContainer {
296+
/// matrix: SharedPointMatrix,
297+
/// }
298+
///
299+
/// fn main() {
300+
/// let point_matrix: PointMatrix = 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 shared_point_matrix: SharedPointMatrix = Rc::new(point_matrix);
311+
///
312+
/// let container = PointMatrixContainer {
313+
/// matrix: shared_point_matrix,
314+
/// };
315+
///
316+
/// // ...
266317
/// }
267318
/// ```
268319
#[clippy::version = "pre 1.29.0"]

0 commit comments

Comments
 (0)