Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update README.md example to use Renderer #70

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ Usage
-----

```rust
use annotate_snippets::{
display_list::{DisplayList, FormatOptions},
snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation},
};
use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation};

fn main() {
let snippet = Snippet {
Expand All @@ -58,7 +55,7 @@ fn main() {
SourceAnnotation {
label: "",
annotation_type: AnnotationType::Error,
range: (187, 189),
range: (193, 195),
},
SourceAnnotation {
label: "while parsing this struct",
Expand All @@ -67,14 +64,10 @@ fn main() {
},
],
}],
opt: FormatOptions {
color: true,
..Default::default()
},
};

let dl = DisplayList::from(snippet);
println!("{}", dl);
let renderer = Renderer::plain();
println!("{}", renderer.render(snippet));
}
```

Expand Down
Loading