From: Ian Jackson Date: Tue, 12 Jan 2021 19:20:17 +0000 (+0000) Subject: otterlib: Sort items in preview X-Git-Tag: otter-0.3.0~63 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=7bd9902b15fc2f0740de84ddcc7b15989b57ddae;p=otter.git otterlib: Sort items in preview Signed-off-by: Ian Jackson --- diff --git a/src/bin/otterlib.rs b/src/bin/otterlib.rs index 63c024c9..9e8a246b 100644 --- a/src/bin/otterlib.rs +++ b/src/bin/otterlib.rs @@ -84,7 +84,7 @@ fn preview(items: Vec) { } } - let pieces : Vec = items.into_iter().map(|it| { + let mut pieces : Vec = items.into_iter().map(|it| { let spec = ItemSpec { lib: it.0, item: it.1.itemname }; (||{ let pc = spec.clone().load().context("load")?; @@ -109,6 +109,9 @@ fn preview(items: Vec) { })().with_context(|| format!("{:?}", &spec)) }).collect::,_>>()?; + // clones as a bodge for https://github.com/rust-lang/rust/issues/34162 + pieces.sort_by_key(|p| (p.spec.item.clone(), p.spec.lib.clone())); + let max_facecols = pieces.iter().map(|s| s.face_cols()).max().unwrap_or(1); let max_uos = pieces.iter().map(|s| s.uos.len()).max().unwrap_or(0);