Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Enforce Rust 2018 idioms#4

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
oli-obk merged 1 commit intorust-lang:masterfrombash:rust-2018-idioms
Jun 11, 2019
Merged
Show file tree
Hide file tree
Changes fromall 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
4 changes: 2 additions & 2 deletionssrc/formatter/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -47,7 +47,7 @@ fn repeat_char(c: char, n: usize) -> String {
/// assert_eq!(dlf.format(&dl), "192 | Example line of text");
/// ```
pub struct DisplayListFormatter {
stylesheet: Box<Stylesheet>,
stylesheet: Box<dynStylesheet>,
}

impl DisplayListFormatter {
Expand DownExpand Up@@ -101,7 +101,7 @@ impl DisplayListFormatter {
}
}

fn get_annotation_style(&self, annotation_type: &DisplayAnnotationType) -> Box<Style> {
fn get_annotation_style(&self, annotation_type: &DisplayAnnotationType) -> Box<dynStyle> {
self.stylesheet.get_style(match annotation_type {
DisplayAnnotationType::Error => StyleClass::Error,
DisplayAnnotationType::Warning => StyleClass::Warning,
Expand Down
4 changes: 2 additions & 2 deletionssrc/formatter/style.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -87,12 +87,12 @@ pub trait Style {
fn paint(&self, text: &str) -> String;
/// The method used by the DisplayListFormatter to display the message
/// in bold font.
fn bold(&self) -> Box<Style>;
fn bold(&self) -> Box<dynStyle>;
}

/// Trait to annotate structs that can provide `Style` implementations for
/// every `StyleClass` variant.
pub trait Stylesheet {
/// Returns a `Style` implementer based on the requested `StyleClass` variant.
fn get_style(&self, class: StyleClass) -> Box<Style>;
fn get_style(&self, class: StyleClass) -> Box<dynStyle>;
}
2 changes: 2 additions & 0 deletionssrc/lib.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
#![deny(rust_2018_idioms)]

//! A library for formatting of text or programming code snippets.
//!
//! It's primary purpose is to build an ASCII-graphical representation of the snippet
Expand Down
4 changes: 2 additions & 2 deletionssrc/stylesheets/no_color.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,15 +7,15 @@ impl Style for NoOpStyle {
text.to_string()
}

fn bold(&self) -> Box<Style> {
fn bold(&self) -> Box<dynStyle> {
Box::new(NoOpStyle {})
}
}

pub struct NoColorStylesheet {}

impl Stylesheet for NoColorStylesheet {
fn get_style(&self, _class: StyleClass) -> Box<Style> {
fn get_style(&self, _class: StyleClass) -> Box<dynStyle> {
Box::new(NoOpStyle {})
}
}

[8]ページ先頭

©2009-2025 Movatter.jp