Skip to content

Commit 3815c16

Browse files
author
Zibi Braniecki
committed
Update to Rust 2018
1 parent bf63ef6 commit 3815c16

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[package]
22
name = "annotate-snippets"
3-
version = "0.1.0"
3+
version = "0.2.0"
4+
edition = "2018"
45
authors = ["Zibi Braniecki <[email protected]>"]
56
description = "Library for building code annotations"
67
license = "Apache-2.0/MIT"

src/display_list/from_snippet.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Trait for converting `Snippet` to `DisplayList`.
22
use super::*;
3-
use snippet;
3+
use crate::snippet;
44

55
fn format_label(label: Option<&str>, style: Option<DisplayTextStyle>) -> Vec<DisplayTextFragment> {
66
let mut result = vec![];

src/formatter/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
pub mod style;
88

99
use self::style::{Style, StyleClass, Stylesheet};
10-
use display_list::*;
10+
use crate::display_list::*;
1111
use std::cmp;
1212

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

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

src/stylesheets/no_color.rs

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

33
pub struct NoOpStyle {}
44

tests/fixtures.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ use annotate_snippets::display_list::DisplayList;
1111
use annotate_snippets::formatter::DisplayListFormatter;
1212
use annotate_snippets::snippet::Snippet;
1313
use glob::glob;
14-
use snippet::SnippetDef;
14+
use crate::snippet::SnippetDef;
1515
use std::error::Error;
1616
use std::fs::File;
1717
use std::io;
1818
use std::io::prelude::*;
1919
use std::path::Path;
2020

2121
fn read_file(path: &str) -> Result<String, io::Error> {
22-
let mut f = try!(File::open(path));
22+
let mut f = File::open(path)?;
2323
let mut s = String::new();
24-
try!(f.read_to_string(&mut s));
25-
Ok(s.trim_right().to_string())
24+
(f.read_to_string(&mut s))?;
25+
Ok(s.trim_end().to_string())
2626
}
2727

2828
fn read_fixture<P: AsRef<Path>>(path: P) -> Result<Snippet, Box<Error>> {
@@ -49,11 +49,11 @@ fn test_fixtures() {
4949
let dlf = DisplayListFormatter::new(true);
5050
let actual_out = dlf.format(&dl);
5151
println!("{}", expected_out);
52-
println!("{}", actual_out.trim_right());
52+
println!("{}", actual_out.trim_end());
5353

5454
assert_eq!(
5555
expected_out,
56-
actual_out.trim_right(),
56+
actual_out.trim_end(),
5757
"\n\n\nWhile parsing: {}\nThe diff is:\n\n\n{}\n\n\n",
5858
path_in,
5959
diff::get_diff(expected_out.as_str(), actual_out.as_str())

0 commit comments

Comments
 (0)