Skip to content

Commit

Permalink
Merge pull request #148 from sftse/errors
Browse files Browse the repository at this point in the history
Make do without fmt::Error
  • Loading branch information
jugglerchris authored May 13, 2024
2 parents dcd0a52 + 5fd0a80 commit 805462d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
3 changes: 1 addition & 2 deletions src/ansi_colours.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//! underlining in some terminals).
use crate::{parse, RichAnnotation, RichDecorator};
use std::fmt::Write;
use std::io;

/// Reads HTML from `input`, and returns text wrapped to `width` columns.
Expand All @@ -32,7 +31,7 @@ where
let mut result = String::new();
for line in lines {
for ts in line.tagged_strings() {
write!(result, "{}", colour_map(&ts.tag, &ts.s))?;
result.push_str(&colour_map(&ts.tag, &ts.s));
}
result.push('\n');
}
Expand Down
12 changes: 2 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@ pub enum Error {
/// An general error was encountered.
#[error("Unknown failure")]
Fail,
/// A formatting error happened
#[error("Formatting error")]
FmtError(#[from] std::fmt::Error),
/// An I/O error
#[error("I/O error")]
IoError(#[from] std::io::Error),
Expand All @@ -152,7 +149,6 @@ impl PartialEq for Error {
#[cfg(feature = "css")]
(CssParseError, CssParseError) => true,
(Fail, Fail) => true,
(FmtError(f1), FmtError(f2)) => f1 == f2,
_ => false,
}
}
Expand Down Expand Up @@ -2162,8 +2158,6 @@ pub mod config {
R: std::io::Read,
FMap: Fn(&[RichAnnotation], &str) -> String,
{
use std::fmt::Write;

let mut context = self.make_context();
let lines = self
.do_parse(&mut context, input)?
Expand All @@ -2173,7 +2167,7 @@ pub mod config {
let mut result = String::new();
for line in lines {
for ts in line.tagged_strings() {
write!(result, "{}", colour_map(&ts.tag, &ts.s))?;
result.push_str(&colour_map(&ts.tag, &ts.s));
}
result.push('\n');
}
Expand All @@ -2192,14 +2186,12 @@ pub mod config {
where
FMap: Fn(&[RichAnnotation], &str) -> String,
{
use std::fmt::Write;

let lines = self.render_to_lines(render_tree, width)?;

let mut result = String::new();
for line in lines {
for ts in line.tagged_strings() {
write!(result, "{}", colour_map(&ts.tag, &ts.s))?;
result.push_str(&colour_map(&ts.tag, &ts.s));
}
result.push('\n');
}
Expand Down

0 comments on commit 805462d

Please sign in to comment.