commit | b596195595457447b20c31016e97ca8c8d625847 | [log] [tgz] |
---|---|---|
author | Andrew Walbran <[email protected]> | Thu Oct 05 14:21:08 2023 +0000 |
committer | Automerger Merge Worker <[email protected]> | Thu Oct 05 14:21:08 2023 +0000 |
tree | 71d1c0ac934fac7bdf457e2b5c76891398247200 | |
parent | eabea2262439dddc29702badfe777fe9bec667c8 [diff] | |
parent | 2eced21a1ff7d3b27da615bce8e74ca10ac97297 [diff] |
Re-run cargo2android.py. am: c0a780afa8 am: c53e4bb321 am: 8d8be55608 am: 2ebfb0c46a am: 2eced21a1f Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/annotate-snippets/+/2774688 Change-Id: I9d760dece3c1b76701ca499cf247a83de50c46cc Signed-off-by: Automerger Merge Worker <[email protected]>
annotate-snippets
is a Rust library for annotation of programming code slices.
The library helps visualize meta information annotating source code slices. It takes a data structure called Snippet
on the input and produces a String
which may look like this:
error[E0308]: mismatched types --> src/format.rs:52:1 | 51 | ) -> Option<String> { | -------------- expected `Option<String>` because of return type 52 | / for ann in annotations { 53 | | match (ann.range.0, ann.range.1) { 54 | | (None, None) => continue, 55 | | (Some(start), Some(end)) if start > end_index => continue, ... | 71 | | } 72 | | } | |_____^ expected enum `std::option::Option`, found ()
use annotate_snippets::{ display_list::{DisplayList, FormatOptions}, snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation}, }; fn main() { let snippet = Snippet { title: Some(Annotation { label: Some("expected type, found `22`"), id: None, annotation_type: AnnotationType::Error, }), footer: vec![], slices: vec![Slice { source: r#" annotations: vec![SourceAnnotation { label: "expected struct `annotate_snippets::snippet::Slice`, found reference" , range: <22, 25>,"#, line_start: 26, origin: Some("examples/footer.rs"), fold: true, annotations: vec![ SourceAnnotation { label: "", annotation_type: AnnotationType::Error, range: (187, 189), }, SourceAnnotation { label: "while parsing this struct", annotation_type: AnnotationType::Info, range: (34, 50), }, ], }], opt: FormatOptions { color: true, ..Default::default() }, }; let dl = DisplayList::from(snippet); println!("{}", dl); }
cargo build cargo test
When submitting a PR please use cargo fmt
(nightly).