Skip to content

Commit

Permalink
fix compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
fkohlgrueber committed Jul 25, 2019
1 parent 11e7549 commit dd4f9a6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ pub mod terminfo;
mod win;

/// Alias for stdout terminals.
pub type StdoutTerminal = Terminal<Output = Stdout> + Send;
pub type StdoutTerminal = dyn Terminal<Output = Stdout> + Send;
/// Alias for stderr terminals.
pub type StderrTerminal = Terminal<Output = Stderr> + Send;
pub type StderrTerminal = dyn Terminal<Output = Stderr> + Send;

#[cfg(not(windows))]
/// Return a Terminal wrapping stdout, or None if a terminal couldn't be
Expand Down Expand Up @@ -280,7 +280,7 @@ impl std::error::Error for Error {
}
}

fn cause(&self) -> Option<&std::error::Error> {
fn cause(&self) -> Option<&dyn std::error::Error> {
match *self {
Error::Io(ref io) => Some(io),
Error::TerminfoParsing(ref e) => Some(e),
Expand Down
6 changes: 3 additions & 3 deletions src/terminfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl TermInfo {
}

/// Retrieve a capability `cmd` and expand it with `params`, writing result to `out`.
pub fn apply_cap(&self, cmd: &str, params: &[Param], out: &mut io::Write) -> Result<()> {
pub fn apply_cap(&self, cmd: &str, params: &[Param], out: &mut dyn io::Write) -> Result<()> {
match self.strings.get(cmd) {
Some(cmd) => match expand(cmd, params, &mut Variables::new()) {
Ok(s) => {
Expand All @@ -153,7 +153,7 @@ impl TermInfo {
}

/// Write the reset string to `out`.
pub fn reset(&self, out: &mut io::Write) -> Result<()> {
pub fn reset(&self, out: &mut dyn io::Write) -> Result<()> {
// are there any terminals that have color/attrs and not sgr0?
// Try falling back to sgr, then op
let cmd = match [
Expand Down Expand Up @@ -236,7 +236,7 @@ impl ::std::error::Error for Error {
}
}

fn cause(&self) -> Option<&::std::error::Error> {
fn cause(&self) -> Option<&dyn (::std::error::Error)> {
match *self {
NotUtf8(ref e) => Some(e),
_ => None,
Expand Down
12 changes: 6 additions & 6 deletions src/terminfo/parm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl ::std::error::Error for Error {
}
}

fn cause(&self) -> Option<&::std::error::Error> {
fn cause(&self) -> Option<&dyn (::std::error::Error)> {
None
}
}
Expand Down Expand Up @@ -264,15 +264,15 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables) -> Result<Vec<
return Err(Error::StackUnderflow);
}
}
':' | '#' | ' ' | '.' | '0'...'9' => {
':' | '#' | ' ' | '.' | '0'..='9' => {
let mut flags = Flags::default();
let mut fstate = FormatState::Flags;
match cur {
':' => (),
'#' => flags.alternate = true,
' ' => flags.space = true,
'.' => fstate = FormatState::Precision,
'0'...'9' => {
'0'..='9' => {
flags.width = cur as usize - '0' as usize;
fstate = FormatState::Width;
}
Expand Down Expand Up @@ -384,11 +384,11 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables) -> Result<Vec<
(FormatState::Flags, ' ') => {
flags.space = true;
}
(FormatState::Flags, '0'...'9') => {
(FormatState::Flags, '0'..='9') => {
flags.width = cur as usize - '0' as usize;
*fstate = FormatState::Width;
}
(FormatState::Width, '0'...'9') => {
(FormatState::Width, '0'..='9') => {
flags.width = match flags
.width
.checked_mul(10)
Expand All @@ -401,7 +401,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables) -> Result<Vec<
(FormatState::Width, '.') | (FormatState::Flags, '.') => {
*fstate = FormatState::Precision;
}
(FormatState::Precision, '0'...'9') => {
(FormatState::Precision, '0'..='9') => {
flags.precision = match flags
.precision
.checked_mul(10)
Expand Down
8 changes: 4 additions & 4 deletions src/terminfo/parser/compiled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ pub use terminfo::parser::names::*;
// These are the orders ncurses uses in its compiled format (as of 5.9). Not
// sure if portable.

fn read_le_u16(r: &mut io::Read) -> io::Result<u32> {
fn read_le_u16(r: &mut dyn io::Read) -> io::Result<u32> {
return r.read_u16::<LittleEndian>().map(|i| i as u32);
}

fn read_le_u32(r: &mut io::Read) -> io::Result<u32> {
fn read_le_u32(r: &mut dyn io::Read) -> io::Result<u32> {
return r.read_u32::<LittleEndian>();
}

fn read_byte(r: &mut io::Read) -> io::Result<u8> {
fn read_byte(r: &mut dyn io::Read) -> io::Result<u8> {
match r.bytes().next() {
Some(s) => s,
None => Err(io::Error::new(io::ErrorKind::Other, "end of file")),
Expand All @@ -42,7 +42,7 @@ fn read_byte(r: &mut io::Read) -> io::Result<u8> {

/// Parse a compiled terminfo entry, using long capability names if `longnames`
/// is true
pub fn parse(file: &mut io::Read, longnames: bool) -> Result<TermInfo> {
pub fn parse(file: &mut dyn io::Read, longnames: bool) -> Result<TermInfo> {
let (bnames, snames, nnames) = if longnames {
(boolfnames, stringfnames, numfnames)
} else {
Expand Down

0 comments on commit dd4f9a6

Please sign in to comment.