Skip to content

Commit 9b92724

Browse files
authored
Merge pull request #4 from bash/rust-2018-idioms
Enforce Rust 2018 idioms
2 parents 61a75ca + 48c08f0 commit 9b92724

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

Diff for: src/formatter/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn repeat_char(c: char, n: usize) -> String {
4747
/// assert_eq!(dlf.format(&dl), "192 | Example line of text");
4848
/// ```
4949
pub struct DisplayListFormatter {
50-
stylesheet: Box<Stylesheet>,
50+
stylesheet: Box<dyn Stylesheet>,
5151
}
5252

5353
impl DisplayListFormatter {
@@ -101,7 +101,7 @@ impl DisplayListFormatter {
101101
}
102102
}
103103

104-
fn get_annotation_style(&self, annotation_type: &DisplayAnnotationType) -> Box<Style> {
104+
fn get_annotation_style(&self, annotation_type: &DisplayAnnotationType) -> Box<dyn Style> {
105105
self.stylesheet.get_style(match annotation_type {
106106
DisplayAnnotationType::Error => StyleClass::Error,
107107
DisplayAnnotationType::Warning => StyleClass::Warning,

Diff for: src/formatter/style.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ pub trait Style {
8787
fn paint(&self, text: &str) -> String;
8888
/// The method used by the DisplayListFormatter to display the message
8989
/// in bold font.
90-
fn bold(&self) -> Box<Style>;
90+
fn bold(&self) -> Box<dyn Style>;
9191
}
9292

9393
/// Trait to annotate structs that can provide `Style` implementations for
9494
/// every `StyleClass` variant.
9595
pub trait Stylesheet {
9696
/// Returns a `Style` implementer based on the requested `StyleClass` variant.
97-
fn get_style(&self, class: StyleClass) -> Box<Style>;
97+
fn get_style(&self, class: StyleClass) -> Box<dyn Style>;
9898
}

Diff for: src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(rust_2018_idioms)]
2+
13
//! A library for formatting of text or programming code snippets.
24
//!
35
//! It's primary purpose is to build an ASCII-graphical representation of the snippet

Diff for: src/stylesheets/no_color.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ impl Style for NoOpStyle {
77
text.to_string()
88
}
99

10-
fn bold(&self) -> Box<Style> {
10+
fn bold(&self) -> Box<dyn Style> {
1111
Box::new(NoOpStyle {})
1212
}
1313
}
1414

1515
pub struct NoColorStylesheet {}
1616

1717
impl Stylesheet for NoColorStylesheet {
18-
fn get_style(&self, _class: StyleClass) -> Box<Style> {
18+
fn get_style(&self, _class: StyleClass) -> Box<dyn Style> {
1919
Box::new(NoOpStyle {})
2020
}
2121
}

0 commit comments

Comments
 (0)