Use rust 2018 idioms

This commit is contained in:
Simon Bruder 2020-08-07 12:45:13 +02:00
parent 73dea88f7d
commit a7efcb2033
No known key found for this signature in database
GPG key ID: 6F03E0000CC5B62F
6 changed files with 24 additions and 23 deletions

View file

@ -20,7 +20,7 @@ impl ConfigRange {
}
impl fmt::Display for ConfigRange {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}:{}", self.0, self.1)
}
}
@ -89,7 +89,7 @@ pub struct ConfigMetadata {
}
impl fmt::Display for Config {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"ddr2osu ({}shock→{:?} hp{} acc{})",

View file

@ -65,7 +65,7 @@ impl Into<Vec<bool>> for PlayerRow {
}
impl fmt::Display for PlayerRow {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"{}{}{}{}",
@ -98,7 +98,7 @@ impl Into<Vec<bool>> for Row {
}
impl fmt::Display for Row {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let player_rows = match self {
Self::Single(player_row) => vec![player_row],
Self::Double(player_row1, player_row2) => vec![player_row1, player_row2],
@ -412,7 +412,7 @@ impl TryFrom<u16> for Level {
}
impl fmt::Display for Level {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let players = match self.players {
1 => "Single",
2 => "Double",

View file

@ -1,4 +1,5 @@
#![warn(clippy::cast_lossless)]
#![warn(rust_2018_idioms)]
#[cfg(test)]
#[macro_use(quickcheck)]

View file

@ -129,7 +129,7 @@ pub struct General {
}
impl fmt::Display for General {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"\
@ -155,7 +155,7 @@ impl fmt::Display for General {
pub struct Editor;
impl fmt::Display for Editor {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "[Editor]")
}
}
@ -175,7 +175,7 @@ pub struct Metadata {
}
impl fmt::Display for Metadata {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"\
@ -238,7 +238,7 @@ impl DifficultyBuilder {
}
impl fmt::Display for Difficulty {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"\
@ -264,7 +264,7 @@ impl fmt::Display for Difficulty {
pub struct Events(pub Vec<Event>);
impl fmt::Display for Events {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"\
@ -296,7 +296,7 @@ pub enum Event {
}
impl fmt::Display for Event {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Event::Background {
filename,
@ -325,7 +325,7 @@ impl fmt::Display for Event {
pub struct TimingPoints(pub Vec<TimingPoint>);
impl fmt::Display for TimingPoints {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"\
@ -344,7 +344,7 @@ pub struct TimingPointEffects {
}
impl fmt::Display for TimingPointEffects {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"{}",
@ -381,7 +381,7 @@ pub struct TimingPoint {
}
impl fmt::Display for TimingPoint {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"{},{},{},{},{},{},{},{}",
@ -401,7 +401,7 @@ impl fmt::Display for TimingPoint {
pub struct Colours(pub Vec<Colour>);
impl fmt::Display for Colours {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"\
@ -421,7 +421,7 @@ pub enum ColourScope {
}
impl fmt::Display for ColourScope {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ColourScope::Combo(i) => write!(f, "Combo{}", i),
_ => write!(f, "{:?}", self),
@ -436,7 +436,7 @@ pub struct Colour {
}
impl fmt::Display for Colour {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"{} : {}",
@ -447,7 +447,7 @@ impl fmt::Display for Colour {
}
impl fmt::Display for HitSound {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"{}",
@ -466,7 +466,7 @@ impl fmt::Display for HitSound {
}
impl fmt::Display for HitSample {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"{}:{}:{}:{}:{}",
@ -483,7 +483,7 @@ impl fmt::Display for HitSample {
pub struct HitObjects(pub Vec<HitObject>);
impl fmt::Display for HitObjects {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"\
@ -513,7 +513,7 @@ pub struct Beatmap {
}
impl fmt::Display for Beatmap {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"osu file format v{}\n\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}",

View file

@ -84,7 +84,7 @@ impl HitObject {
}
impl fmt::Display for HitObject {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
HitObject::HitCircle(HitCircle {
x,

View file

@ -193,7 +193,7 @@ pub struct WaveBank<'a> {
}
impl WaveBank<'_> {
pub fn parse(data: &'_ [u8]) -> Result<WaveBank, Error> {
pub fn parse(data: &'_ [u8]) -> Result<WaveBank<'_>, Error> {
debug!("Parsing header");
let header = Header::parse(mini_parser::get_slice_range(data, 0..52)?)?;