Use rust 2018 idioms
This commit is contained in:
parent
73dea88f7d
commit
a7efcb2033
|
@ -20,7 +20,7 @@ impl ConfigRange {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for 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)
|
write!(f, "{}:{}", self.0, self.1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ pub struct ConfigMetadata {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Config {
|
impl fmt::Display for Config {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"ddr2osu ({}shock→{:?} hp{} acc{})",
|
"ddr2osu ({}shock→{:?} hp{} acc{})",
|
||||||
|
|
|
@ -65,7 +65,7 @@ impl Into<Vec<bool>> for PlayerRow {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display 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!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"{}{}{}{}",
|
"{}{}{}{}",
|
||||||
|
@ -98,7 +98,7 @@ impl Into<Vec<bool>> for Row {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display 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 {
|
let player_rows = match self {
|
||||||
Self::Single(player_row) => vec![player_row],
|
Self::Single(player_row) => vec![player_row],
|
||||||
Self::Double(player_row1, player_row2) => vec![player_row1, player_row2],
|
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 {
|
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 {
|
let players = match self.players {
|
||||||
1 => "Single",
|
1 => "Single",
|
||||||
2 => "Double",
|
2 => "Double",
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#![warn(clippy::cast_lossless)]
|
#![warn(clippy::cast_lossless)]
|
||||||
|
#![warn(rust_2018_idioms)]
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[macro_use(quickcheck)]
|
#[macro_use(quickcheck)]
|
||||||
|
|
|
@ -129,7 +129,7 @@ pub struct General {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for 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!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"\
|
"\
|
||||||
|
@ -155,7 +155,7 @@ impl fmt::Display for General {
|
||||||
pub struct Editor;
|
pub struct Editor;
|
||||||
|
|
||||||
impl fmt::Display for 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]")
|
writeln!(f, "[Editor]")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ pub struct Metadata {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for 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!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"\
|
"\
|
||||||
|
@ -238,7 +238,7 @@ impl DifficultyBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Difficulty {
|
impl fmt::Display for Difficulty {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"\
|
"\
|
||||||
|
@ -264,7 +264,7 @@ impl fmt::Display for Difficulty {
|
||||||
pub struct Events(pub Vec<Event>);
|
pub struct Events(pub Vec<Event>);
|
||||||
|
|
||||||
impl fmt::Display for Events {
|
impl fmt::Display for Events {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"\
|
"\
|
||||||
|
@ -296,7 +296,7 @@ pub enum Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for 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 {
|
match self {
|
||||||
Event::Background {
|
Event::Background {
|
||||||
filename,
|
filename,
|
||||||
|
@ -325,7 +325,7 @@ impl fmt::Display for Event {
|
||||||
pub struct TimingPoints(pub Vec<TimingPoint>);
|
pub struct TimingPoints(pub Vec<TimingPoint>);
|
||||||
|
|
||||||
impl fmt::Display for TimingPoints {
|
impl fmt::Display for TimingPoints {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"\
|
"\
|
||||||
|
@ -344,7 +344,7 @@ pub struct TimingPointEffects {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for 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!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"{}",
|
"{}",
|
||||||
|
@ -381,7 +381,7 @@ pub struct TimingPoint {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for 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!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"{},{},{},{},{},{},{},{}",
|
"{},{},{},{},{},{},{},{}",
|
||||||
|
@ -401,7 +401,7 @@ impl fmt::Display for TimingPoint {
|
||||||
pub struct Colours(pub Vec<Colour>);
|
pub struct Colours(pub Vec<Colour>);
|
||||||
|
|
||||||
impl fmt::Display for Colours {
|
impl fmt::Display for Colours {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"\
|
"\
|
||||||
|
@ -421,7 +421,7 @@ pub enum ColourScope {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for 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 {
|
match self {
|
||||||
ColourScope::Combo(i) => write!(f, "Combo{}", i),
|
ColourScope::Combo(i) => write!(f, "Combo{}", i),
|
||||||
_ => write!(f, "{:?}", self),
|
_ => write!(f, "{:?}", self),
|
||||||
|
@ -436,7 +436,7 @@ pub struct Colour {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for 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!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"{} : {}",
|
"{} : {}",
|
||||||
|
@ -447,7 +447,7 @@ impl fmt::Display for Colour {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for HitSound {
|
impl fmt::Display for HitSound {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"{}",
|
"{}",
|
||||||
|
@ -466,7 +466,7 @@ impl fmt::Display for HitSound {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for HitSample {
|
impl fmt::Display for HitSample {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"{}:{}:{}:{}:{}",
|
"{}:{}:{}:{}:{}",
|
||||||
|
@ -483,7 +483,7 @@ impl fmt::Display for HitSample {
|
||||||
pub struct HitObjects(pub Vec<HitObject>);
|
pub struct HitObjects(pub Vec<HitObject>);
|
||||||
|
|
||||||
impl fmt::Display for HitObjects {
|
impl fmt::Display for HitObjects {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"\
|
"\
|
||||||
|
@ -513,7 +513,7 @@ pub struct Beatmap {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for 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!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"osu file format v{}\n\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}",
|
"osu file format v{}\n\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}",
|
||||||
|
|
|
@ -84,7 +84,7 @@ impl HitObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for 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 {
|
match self {
|
||||||
HitObject::HitCircle(HitCircle {
|
HitObject::HitCircle(HitCircle {
|
||||||
x,
|
x,
|
||||||
|
|
|
@ -193,7 +193,7 @@ pub struct WaveBank<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WaveBank<'_> {
|
impl WaveBank<'_> {
|
||||||
pub fn parse(data: &'_ [u8]) -> Result<WaveBank, Error> {
|
pub fn parse(data: &'_ [u8]) -> Result<WaveBank<'_>, Error> {
|
||||||
debug!("Parsing header");
|
debug!("Parsing header");
|
||||||
let header = Header::parse(mini_parser::get_slice_range(data, 0..52)?)?;
|
let header = Header::parse(mini_parser::get_slice_range(data, 0..52)?)?;
|
||||||
|
|
||||||
|
|
Reference in a new issue