Skip to content

Commit 1ace49e

Browse files
author
Zibi Braniecki
committed
Clean up the code after 2018 update
1 parent 3815c16 commit 1ace49e

File tree

7 files changed

+24
-22
lines changed

7 files changed

+24
-22
lines changed

Cargo.toml

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "annotate-snippets"
3-
version = "0.2.0"
3+
version = "0.5.0"
44
edition = "2018"
55
authors = ["Zibi Braniecki <[email protected]>"]
66
description = "Library for building code annotations"
@@ -19,12 +19,12 @@ maintenance = { status = "actively-developed" }
1919
ansi_term = { version = "0.11.0", optional = true }
2020

2121
[dev-dependencies]
22-
glob = "0.2"
23-
serde_yaml = "0.7"
24-
serde = "1.0"
25-
serde_derive = "1.0"
26-
difference = "2.0"
27-
ansi_term = "0.11"
22+
glob = "^0.2"
23+
serde_yaml = "^0.8"
24+
serde = "^1.0"
25+
serde_derive = "^1.0"
26+
difference = "^2.0"
27+
ansi_term = "^0.11"
2828

2929
[features]
3030
default = []

examples/expected_type.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ fn main() {
1616
source: r#" annotations: vec![SourceAnnotation {
1717
label: "expected struct `annotate_snippets::snippet::Slice`, found reference"
1818
.to_string(),
19-
range: <22, 25>,"#.to_string(),
19+
range: <22, 25>,"#
20+
.to_string(),
2021
line_start: 26,
2122
origin: Some("examples/footer.rs".to_string()),
2223
fold: true,

examples/format.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ fn main() {
2828
}
2929
_ => continue,
3030
}
31-
}"#.to_string(),
31+
}"#
32+
.to_string(),
3233
line_start: 51,
3334
origin: Some("src/format.rs".to_string()),
3435
fold: false,

src/display_list/from_snippet.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ fn format_label(label: Option<&str>, style: Option<DisplayTextStyle>) -> Vec<Dis
99
for (idx, element) in elements.iter().enumerate() {
1010
let element_style = match style {
1111
Some(s) => s,
12-
None => if idx % 2 == 0 {
13-
DisplayTextStyle::Regular
14-
} else {
15-
DisplayTextStyle::Emphasis
16-
},
12+
None => {
13+
if idx % 2 == 0 {
14+
DisplayTextStyle::Regular
15+
} else {
16+
DisplayTextStyle::Emphasis
17+
}
18+
}
1719
};
1820
result.push(DisplayTextFragment {
1921
content: element.to_string(),

src/formatter/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ use self::style::{Style, StyleClass, Stylesheet};
1010
use crate::display_list::*;
1111
use std::cmp;
1212

13-
#[cfg(feature = "ansi_term")]
14-
use stylesheets::color::AnsiTermStylesheet;
1513
use crate::stylesheets::no_color::NoColorStylesheet;
14+
#[cfg(feature = "ansi_term")]
15+
use crate::stylesheets::color::AnsiTermStylesheet;
1616

1717
fn repeat_char(c: char, n: usize) -> String {
1818
let mut s = String::with_capacity(c.len_utf8());

src/stylesheets/color.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
use formatter::style::{Style, StyleClass, Stylesheet};
1+
use crate::formatter::style::{Style, StyleClass, Stylesheet};
22

3-
extern crate ansi_term;
4-
5-
use self::ansi_term::Color::Fixed;
6-
use self::ansi_term::Style as AnsiTermStyle;
3+
use ansi_term::Color::Fixed;
4+
use ansi_term::Style as AnsiTermStyle;
75

86
struct AnsiTermStyleWrapper {
97
style: AnsiTermStyle,

tests/fixtures.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ extern crate glob;
77
extern crate serde_derive;
88
extern crate serde_yaml;
99

10+
use crate::snippet::SnippetDef;
1011
use annotate_snippets::display_list::DisplayList;
1112
use annotate_snippets::formatter::DisplayListFormatter;
1213
use annotate_snippets::snippet::Snippet;
1314
use glob::glob;
14-
use crate::snippet::SnippetDef;
1515
use std::error::Error;
1616
use std::fs::File;
1717
use std::io;

0 commit comments

Comments
 (0)