Remove unstable options from rustfmt.toml

This commit is contained in:
kageru 2020-07-23 21:03:54 +02:00
parent 6bf85ca664
commit bc44cc23ae
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2
3 changed files with 86 additions and 80 deletions

View File

@ -1,8 +1,4 @@
newline_style = "Unix" newline_style = "Unix"
max_width = 140 max_width = 140
tab_spaces = 2 tab_spaces = 2
imports_layout = "Horizontal"
merge_imports = true
struct_field_align_threshold = 25
where_single_line = true
edition = "2018" edition = "2018"

View File

@ -18,9 +18,7 @@ impl Error {
impl de::Error for Error { impl de::Error for Error {
fn custom<T: Display>(msg: T) -> Self { fn custom<T: Display>(msg: T) -> Self {
Error { Error { message: msg.to_string() }
message: msg.to_string(),
}
} }
} }

View File

@ -158,20 +158,26 @@ mod helpers {
/// Deserialize time from an integer that represents the seconds. /// Deserialize time from an integer that represents the seconds.
/// mpd uses int for the database stats (e.g. total time played). /// mpd uses int for the database stats (e.g. total time played).
pub fn de_time_int<'de, D>(deserializer: D) -> Result<Duration, D::Error> pub fn de_time_int<'de, D>(deserializer: D) -> Result<Duration, D::Error>
where D: de::Deserializer<'de> { where
D: de::Deserializer<'de>,
{
u64::deserialize(deserializer).map(Duration::from_secs) u64::deserialize(deserializer).map(Duration::from_secs)
} }
/// Deserialize time from a float that represents the seconds. /// Deserialize time from a float that represents the seconds.
/// mpd uses floats for the current status (e.g. time elapsed in song). /// mpd uses floats for the current status (e.g. time elapsed in song).
pub fn de_time_float<'de, D>(deserializer: D) -> Result<Option<Duration>, D::Error> pub fn de_time_float<'de, D>(deserializer: D) -> Result<Option<Duration>, D::Error>
where D: de::Deserializer<'de> { where
D: de::Deserializer<'de>,
{
f64::deserialize(deserializer).map(Duration::from_secs_f64).map(Some) f64::deserialize(deserializer).map(Duration::from_secs_f64).map(Some)
} }
/// Deserialize the playback state. /// Deserialize the playback state.
pub fn de_state<'de, D>(deserializer: D) -> Result<State, D::Error> pub fn de_state<'de, D>(deserializer: D) -> Result<State, D::Error>
where D: de::Deserializer<'de> { where
D: de::Deserializer<'de>,
{
match String::deserialize(deserializer)?.as_ref() { match String::deserialize(deserializer)?.as_ref() {
"play" => Ok(State::Play), "play" => Ok(State::Play),
"pause" => Ok(State::Pause), "pause" => Ok(State::Pause),
@ -184,14 +190,18 @@ mod helpers {
} }
pub fn de_string_or_vec<'de, D>(deserializer: D) -> Result<Vec<String>, D::Error> pub fn de_string_or_vec<'de, D>(deserializer: D) -> Result<Vec<String>, D::Error>
where D: de::Deserializer<'de> { where
D: de::Deserializer<'de>,
{
String::deserialize(deserializer).map(|s| s.split(SEPARATOR).map(std::string::String::from).collect()) String::deserialize(deserializer).map(|s| s.split(SEPARATOR).map(std::string::String::from).collect())
} }
/// mpd uses bints (0 or 1) to represent booleans, /// mpd uses bints (0 or 1) to represent booleans,
/// so we need a special parser for those. /// so we need a special parser for those.
pub fn de_bint<'de, D>(deserializer: D) -> Result<bool, D::Error> pub fn de_bint<'de, D>(deserializer: D) -> Result<bool, D::Error>
where D: de::Deserializer<'de> { where
D: de::Deserializer<'de>,
{
match u8::deserialize(deserializer)? { match u8::deserialize(deserializer)? {
0 => Ok(false), 0 => Ok(false),
1 => Ok(true), 1 => Ok(true),
@ -202,7 +212,9 @@ mod helpers {
/// Deserialize a position with an optional total length. /// Deserialize a position with an optional total length.
/// The input string here is either a number or two numbers separated by `SEPARATOR`. /// The input string here is either a number or two numbers separated by `SEPARATOR`.
pub fn de_position<'de, D>(deserializer: D) -> Result<Option<Position>, D::Error> pub fn de_position<'de, D>(deserializer: D) -> Result<Option<Position>, D::Error>
where D: de::Deserializer<'de> { where
D: de::Deserializer<'de>,
{
let s = String::deserialize(deserializer)?; let s = String::deserialize(deserializer)?;
let mut ints = s.split(SEPARATOR).filter_map(|s| u16::from_str(s).ok()); let mut ints = s.split(SEPARATOR).filter_map(|s| u16::from_str(s).ok());
if let Some(n) = ints.next() { if let Some(n) = ints.next() {