Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy recommendations and compiler warnings #71

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ser/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ where
End: for<'key> FnOnce(Key<'key>) -> Result<Ok, Error>,
{
pub fn new(end: End) -> Self {
KeySink { end: end }
KeySink { end }
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/ser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl<'input, 'output, Target: 'output + UrlEncodedTarget> Serializer<'input, 'ou
/// Returns a new `Serializer`.
pub fn new(urlencoder: &'output mut UrlEncodedSerializer<'input, Target>) -> Self {
Serializer {
urlencoder: urlencoder,
urlencoder,
}
}
}
Expand All @@ -72,6 +72,7 @@ impl fmt::Display for Error {
}

impl error::Error for Error {
#[allow(deprecated)]
fn description(&self) -> &str {
match *self {
Error::Custom(ref msg) => msg,
Expand All @@ -80,7 +81,7 @@ impl error::Error for Error {
}

/// The lower-level cause of this error, in the case of a `Utf8` error.
fn cause(&self) -> Option<&error::Error> {
fn cause(&self) -> Option<&dyn error::Error> {
match *self {
Error::Custom(_) => None,
Error::Utf8(ref err) => Some(err),
Expand Down Expand Up @@ -478,7 +479,7 @@ where
value: &T,
) -> Result<(), Error> {
{
let key = self.key.as_ref().ok_or_else(|| Error::no_key())?;
let key = self.key.as_ref().ok_or_else(Error::no_key)?;
let value_sink = value::ValueSink::new(self.urlencoder, &key);
value.serialize(part::PartSerializer::new(value_sink))?;
}
Expand Down
4 changes: 2 additions & 2 deletions src/ser/pair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ where
{
pub fn new(urlencoder: &'target mut UrlEncodedSerializer<'input, Target>) -> Self {
PairSerializer {
urlencoder: urlencoder,
urlencoder,
state: PairState::WaitingForKey,
}
}
Expand Down Expand Up @@ -229,7 +229,7 @@ where
if result.is_ok() {
self.state = PairState::Done;
} else {
self.state = PairState::WaitingForValue { key: key };
self.state = PairState::WaitingForValue { key };
}
result
},
Expand Down
6 changes: 3 additions & 3 deletions src/ser/part.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct PartSerializer<S> {

impl<S: Sink> PartSerializer<S> {
pub fn new(sink: S) -> Self {
PartSerializer { sink: sink }
PartSerializer { sink }
}
}

Expand Down Expand Up @@ -110,7 +110,7 @@ impl<S: Sink> ser::Serializer for PartSerializer<S> {
}

fn serialize_unit_struct(self, name: &'static str) -> Result<S::Ok, Error> {
self.sink.serialize_static_str(name.into())
self.sink.serialize_static_str(name)
}

fn serialize_unit_variant(
Expand All @@ -119,7 +119,7 @@ impl<S: Sink> ser::Serializer for PartSerializer<S> {
_variant_index: u32,
variant: &'static str,
) -> Result<S::Ok, Error> {
self.sink.serialize_static_str(variant.into())
self.sink.serialize_static_str(variant)
}

fn serialize_newtype_struct<T: ?Sized + ser::Serialize>(
Expand Down
4 changes: 2 additions & 2 deletions src/ser/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ where
key: &'key str,
) -> Self {
ValueSink {
urlencoder: urlencoder,
key: key,
urlencoder,
key,
}
}
}
Expand Down