aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2019-05-09 06:49:11 -0700
committerGitHub <noreply@github.com>2019-05-09 06:49:11 -0700
commite887edc70f0341cfbf37f646b6213d6fb6e00439 (patch)
tree63e2a9104a1c0ed297edd2ae41bd4536fde2ce0d /src
parent320464be3b014deaaf9387583862b1d4a69d89f8 (diff)
parent0fca4dd2d30a2044af454cf55211e67cf76f333c (diff)
downloadmilf-rs-e887edc70f0341cfbf37f646b6213d6fb6e00439.tar.gz
milf-rs-e887edc70f0341cfbf37f646b6213d6fb6e00439.zip
Merge pull request #308 from ehuss/edition-2018
Migrate to 2018 edition
Diffstat (limited to 'src')
-rw-r--r--src/datetime.rs22
-rw-r--r--src/de.rs24
-rw-r--r--src/lib.rs22
-rw-r--r--src/macros.rs7
-rw-r--r--src/map.rs30
-rw-r--r--src/ser.rs26
-rw-r--r--src/spanned.rs7
-rw-r--r--src/tokens.rs10
-rw-r--r--src/value.rs159
9 files changed, 143 insertions, 164 deletions
diff --git a/src/datetime.rs b/src/datetime.rs
index b77621a..61eb3b1 100644
--- a/src/datetime.rs
+++ b/src/datetime.rs
@@ -65,13 +65,13 @@ enum Offset {
}
impl fmt::Debug for Datetime {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(self, f)
}
}
impl fmt::Display for Datetime {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if let Some(ref date) = self.date {
write!(f, "{}", date)?;
}
@@ -89,13 +89,13 @@ impl fmt::Display for Datetime {
}
impl fmt::Display for Date {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:04}-{:02}-{:02}", self.year, self.month, self.day)
}
}
impl fmt::Display for Time {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:02}:{:02}:{:02}", self.hour, self.minute, self.second)?;
if self.nanosecond != 0 {
let s = format!("{:09}", self.nanosecond);
@@ -106,7 +106,7 @@ impl fmt::Display for Time {
}
impl fmt::Display for Offset {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
Offset::Z => write!(f, "Z"),
Offset::Custom { hours, minutes } => write!(f, "{:+03}:{:02}", hours, minutes),
@@ -207,7 +207,7 @@ impl FromStr for Datetime {
let mut end = whole.len();
for (i, byte) in whole.bytes().enumerate() {
match byte {
- b'0'...b'9' => {
+ b'0'..=b'9' => {
if i < 9 {
let p = 10_u32.pow(8 - i as u32);
nanosecond += p * (byte - b'0') as u32;
@@ -298,7 +298,7 @@ impl FromStr for Datetime {
}
}
-fn digit(chars: &mut str::Chars) -> Result<u8, DatetimeParseError> {
+fn digit(chars: &mut str::Chars<'_>) -> Result<u8, DatetimeParseError> {
match chars.next() {
Some(c) if '0' <= c && c <= '9' => Ok(c as u8 - b'0'),
_ => Err(DatetimeParseError { _private: () }),
@@ -328,7 +328,7 @@ impl<'de> de::Deserialize<'de> for Datetime {
impl<'de> de::Visitor<'de> for DatetimeVisitor {
type Value = Datetime;
- fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+ fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("a TOML datetime")
}
@@ -362,7 +362,7 @@ impl<'de> de::Deserialize<'de> for DatetimeKey {
impl<'de> de::Visitor<'de> for FieldVisitor {
type Value = ();
- fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+ fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("a valid datetime field")
}
@@ -397,7 +397,7 @@ impl<'de> de::Deserialize<'de> for DatetimeFromString {
impl<'de> de::Visitor<'de> for Visitor {
type Value = DatetimeFromString;
- fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+ fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("string containing a datetime")
}
@@ -417,7 +417,7 @@ impl<'de> de::Deserialize<'de> for DatetimeFromString {
}
impl fmt::Display for DatetimeParseError {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
"failed to parse datetime".fmt(f)
}
}
diff --git a/src/de.rs b/src/de.rs
index b23f03f..077c008 100644
--- a/src/de.rs
+++ b/src/de.rs
@@ -15,9 +15,9 @@ use serde::de;
use serde::de::value::BorrowedStrDeserializer;
use serde::de::IntoDeserializer;
-use datetime;
-use spanned;
-use tokens::{Error as TokenError, Span, Token, Tokenizer};
+use crate::datetime;
+use crate::spanned;
+use crate::tokens::{Error as TokenError, Span, Token, Tokenizer};
/// Deserializes a byte slice into a type.
///
@@ -41,9 +41,7 @@ where
/// # Examples
///
/// ```
-/// #[macro_use]
-/// extern crate serde_derive;
-/// extern crate toml;
+/// use serde_derive::Deserialize;
///
/// #[derive(Deserialize)]
/// struct Config {
@@ -265,7 +263,7 @@ impl<'de, 'b> de::Deserializer<'de> for &'b mut Deserializer<'de> {
}
}
- forward_to_deserialize_any! {
+ serde::forward_to_deserialize_any! {
bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string seq
bytes byte_buf map struct unit newtype_struct
ignored_any unit_struct tuple_struct tuple option identifier
@@ -495,7 +493,7 @@ impl<'de, 'b> de::Deserializer<'de> for MapVisitor<'de, 'b> {
visitor.visit_newtype_struct(self)
}
- forward_to_deserialize_any! {
+ serde::forward_to_deserialize_any! {
bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string seq
bytes byte_buf map struct unit identifier
ignored_any unit_struct tuple_struct tuple enum
@@ -525,7 +523,7 @@ impl<'de> de::Deserializer<'de> for StrDeserializer<'de> {
}
}
- forward_to_deserialize_any! {
+ serde::forward_to_deserialize_any! {
bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string seq
bytes byte_buf map struct option unit newtype_struct
ignored_any unit_struct tuple_struct tuple enum identifier
@@ -699,7 +697,7 @@ impl<'de> de::Deserializer<'de> for ValueDeserializer<'de> {
visitor.visit_newtype_struct(self)
}
- forward_to_deserialize_any! {
+ serde::forward_to_deserialize_any! {
bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string seq
bytes byte_buf map unit identifier
ignored_any unit_struct tuple_struct tuple
@@ -796,7 +794,7 @@ impl<'de> de::Deserializer<'de> for DatetimeFieldDeserializer {
visitor.visit_borrowed_str(datetime::FIELD)
}
- forward_to_deserialize_any! {
+ serde::forward_to_deserialize_any! {
bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string seq
bytes byte_buf map struct option unit newtype_struct
ignored_any unit_struct tuple_struct tuple enum identifier
@@ -1520,7 +1518,7 @@ impl<'a> Deserializer<'a> {
fn array(&mut self) -> Result<(Span, Vec<Value<'a>>), Error> {
let mut ret = Vec::new();
- let intermediate = |me: &mut Deserializer| {
+ let intermediate = |me: &mut Deserializer<'_>| {
loop {
me.eat_whitespace()?;
if !me.eat(Token::Newline)? && !me.eat_comment()? {
@@ -1775,7 +1773,7 @@ impl Error {
}
impl fmt::Display for Error {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.inner.kind {
ErrorKind::UnexpectedEof => "unexpected eof encountered".fmt(f)?,
ErrorKind::InvalidCharInString(c) => write!(
diff --git a/src/lib.rs b/src/lib.rs
index e71f9f2..30ee3bc 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -77,9 +77,7 @@
//! An example of deserializing with TOML is:
//!
//! ```rust
-//! #[macro_use]
-//! extern crate serde_derive;
-//! extern crate toml;
+//! use serde_derive::Deserialize;
//!
//! #[derive(Deserialize)]
//! struct Config {
@@ -113,9 +111,7 @@
//! You can serialize types in a similar fashion:
//!
//! ```rust
-//! #[macro_use]
-//! extern crate serde_derive;
-//! extern crate toml;
+//! use serde_derive::Serialize;
//!
//! #[derive(Serialize)]
//! struct Config {
@@ -150,24 +146,20 @@
#![doc(html_root_url = "https://docs.rs/toml/0.5")]
#![deny(missing_docs)]
-
-#[macro_use]
-extern crate serde;
-#[cfg(feature = "preserve_order")]
-extern crate linked_hash_map;
+#![warn(rust_2018_idioms)]
pub mod map;
pub mod value;
#[doc(no_inline)]
-pub use value::Value;
+pub use crate::value::Value;
mod datetime;
pub mod ser;
#[doc(no_inline)]
-pub use ser::{to_string, to_string_pretty, to_vec, Serializer};
+pub use crate::ser::{to_string, to_string_pretty, to_vec, Serializer};
pub mod de;
#[doc(no_inline)]
-pub use de::{from_slice, from_str, Deserializer};
+pub use crate::de::{from_slice, from_str, Deserializer};
mod tokens;
#[doc(hidden)]
@@ -175,4 +167,4 @@ pub mod macros;
mod spanned;
#[doc(no_inline)]
-pub use spanned::Spanned;
+pub use crate::spanned::Spanned;
diff --git a/src/macros.rs b/src/macros.rs
index 57fdabb..0731afe 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -1,17 +1,14 @@
pub use serde::de::{Deserialize, IntoDeserializer};
-use value::{Array, Table, Value};
+use crate::value::{Array, Table, Value};
/// Construct a [`toml::Value`] from TOML syntax.
///
/// [`toml::Value`]: value/enum.Value.html
///
/// ```rust
-/// #[macro_use]
-/// extern crate toml;
-///
/// fn main() {
-/// let cargo_toml = toml! {
+/// let cargo_toml = toml::toml! {
/// [package]
/// name = "toml"
/// version = "0.4.5"
diff --git a/src/map.rs b/src/map.rs
index 59ae24e..b6e00b0 100644
--- a/src/map.rs
+++ b/src/map.rs
@@ -14,12 +14,12 @@
//! [`BTreeMap`]: https://doc.rust-lang.org/std/collections/struct.BTreeMap.html
//! [`LinkedHashMap`]: https://docs.rs/linked-hash-map/*/linked_hash_map/struct.LinkedHashMap.html
+use crate::value::Value;
use serde::{de, ser};
+use std::borrow::Borrow;
use std::fmt::{self, Debug};
-use value::Value;
use std::hash::Hash;
use std::iter::FromIterator;
-use std::borrow::Borrow;
use std::ops;
#[cfg(not(feature = "preserve_order"))]
@@ -140,14 +140,14 @@ impl Map<String, Value> {
/// Gets the given key's corresponding entry in the map for in-place
/// manipulation.
- pub fn entry<S>(&mut self, key: S) -> Entry
+ pub fn entry<S>(&mut self, key: S) -> Entry<'_>
where
S: Into<String>,
{
- #[cfg(not(feature = "preserve_order"))]
- use std::collections::btree_map::Entry as EntryImpl;
#[cfg(feature = "preserve_order")]
use linked_hash_map::Entry as EntryImpl;
+ #[cfg(not(feature = "preserve_order"))]
+ use std::collections::btree_map::Entry as EntryImpl;
match self.map.entry(key.into()) {
EntryImpl::Vacant(vacant) => Entry::Vacant(VacantEntry { vacant: vacant }),
@@ -169,7 +169,7 @@ impl Map<String, Value> {
/// Gets an iterator over the entries of the map.
#[inline]
- pub fn iter(&self) -> Iter {
+ pub fn iter(&self) -> Iter<'_> {
Iter {
iter: self.map.iter(),
}
@@ -177,7 +177,7 @@ impl Map<String, Value> {
/// Gets a mutable iterator over the entries of the map.
#[inline]
- pub fn iter_mut(&mut self) -> IterMut {
+ pub fn iter_mut(&mut self) -> IterMut<'_> {
IterMut {
iter: self.map.iter_mut(),
}
@@ -185,7 +185,7 @@ impl Map<String, Value> {
/// Gets an iterator over the keys of the map.
#[inline]
- pub fn keys(&self) -> Keys {
+ pub fn keys(&self) -> Keys<'_> {
Keys {
iter: self.map.keys(),
}
@@ -193,7 +193,7 @@ impl Map<String, Value> {
/// Gets an iterator over the values of the map.
#[inline]
- pub fn values(&self) -> Values {
+ pub fn values(&self) -> Values<'_> {
Values {
iter: self.map.values(),
}
@@ -253,7 +253,7 @@ where
impl Debug for Map<String, Value> {
#[inline]
- fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
+ fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
self.map.fmt(formatter)
}
}
@@ -265,10 +265,10 @@ impl ser::Serialize for Map<String, Value> {
S: ser::Serializer,
{
use serde::ser::SerializeMap;
- let mut map = try!(serializer.serialize_map(Some(self.len())));
+ let mut map = serializer.serialize_map(Some(self.len()))?;
for (k, v) in self {
- try!(map.serialize_key(k));
- try!(map.serialize_value(v));
+ map.serialize_key(k)?;
+ map.serialize_value(v)?;
}
map.end()
}
@@ -285,7 +285,7 @@ impl<'de> de::Deserialize<'de> for Map<String, Value> {
impl<'de> de::Visitor<'de> for Visitor {
type Value = Map<String, Value>;
- fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+ fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("a map")
}
@@ -304,7 +304,7 @@ impl<'de> de::Deserialize<'de> for Map<String, Value> {
{
let mut values = Map::new();
- while let Some((key, value)) = try!(visitor.next_entry()) {
+ while let Some((key, value)) = visitor.next_entry()? {
values.insert(key, value);
}
diff --git a/src/ser.rs b/src/ser.rs
index 60e5b50..328772a 100644
--- a/src/ser.rs
+++ b/src/ser.rs
@@ -12,8 +12,7 @@
//! may use the `tables_last` function in this module like so:
//!
//! ```rust
-//! # #[macro_use] extern crate serde_derive;
-//! # extern crate toml;
+//! # use serde_derive::Serialize;
//! # use std::collections::HashMap;
//! #[derive(Serialize)]
//! struct Manifest {
@@ -32,7 +31,7 @@ use std::fmt::{self, Write};
use std::marker;
use std::rc::Rc;
-use datetime;
+use crate::datetime;
use serde::ser;
/// Serialize the given data structure as a TOML byte vector.
@@ -56,9 +55,7 @@ where
/// # Examples
///
/// ```
-/// #[macro_use]
-/// extern crate serde_derive;
-/// extern crate toml;
+/// use serde_derive::Serialize;
///
/// #[derive(Serialize)]
/// struct Config {
@@ -442,7 +439,7 @@ impl<'a> Serializer<'a> {
}
// recursive implementation of `emit_key` above
- fn _emit_key(&mut self, state: &State) -> Result<(), Error> {
+ fn _emit_key(&mut self, state: &State<'_>) -> Result<(), Error> {
match *state {
State::End => Ok(()),
State::Array {
@@ -479,7 +476,7 @@ impl<'a> Serializer<'a> {
fn emit_array(&mut self, first: &Cell<bool>, len: Option<usize>) -> Result<(), Error> {
match (len, &self.settings.array) {
- (Some(0...1), _) | (_, &None) => {
+ (Some(0..=1), _) | (_, &None) => {
if first.get() {
self.dst.push_str("[")
} else {
@@ -517,7 +514,7 @@ impl<'a> Serializer<'a> {
fn escape_key(&mut self, key: &str) -> Result<(), Error> {
let ok = key.chars().all(|c| match c {
- 'a'...'z' | 'A'...'Z' | '0'...'9' | '-' | '_' => true,
+ 'a'..='z' | 'A'..='Z' | '0'..='9' | '-' | '_' => true,
_ => false,
});
if ok {
@@ -666,7 +663,7 @@ impl<'a> Serializer<'a> {
Ok(())
}
- fn emit_table_header(&mut self, state: &State) -> Result<(), Error> {
+ fn emit_table_header(&mut self, state: &State<'_>) -> Result<(), Error> {
let array_of_tables = match *state {
State::End => return Ok(()),
State::Array { .. } => true,
@@ -730,7 +727,7 @@ impl<'a> Serializer<'a> {
Ok(())
}
- fn emit_key_part(&mut self, key: &State) -> Result<bool, Error> {
+ fn emit_key_part(&mut self, key: &State<'_>) -> Result<bool, Error> {
match *key {
State::Array { parent, .. } => self.emit_key_part(parent),
State::End => Ok(true),
@@ -997,7 +994,7 @@ impl<'a, 'b> ser::SerializeSeq for SerializeSeq<'a, 'b> {
match self.type_.get() {
Some("table") => return Ok(()),
Some(_) => match (self.len, &self.ser.settings.array) {
- (Some(0...1), _) | (_, &None) => {
+ (Some(0..=1), _) | (_, &None) => {
self.ser.dst.push_str("]");
}
(_, &Some(ref a)) => {
@@ -1531,7 +1528,7 @@ impl ser::Serializer for StringExtractor {
}
impl fmt::Display for Error {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
Error::UnsupportedType => "unsupported Rust type".fmt(f),
Error::KeyNotString => "map key was not a string".fmt(f),
@@ -1584,8 +1581,7 @@ enum Category {
/// helper can be used like so:
///
/// ```rust
-/// # #[macro_use] extern crate serde_derive;
-/// # extern crate toml;
+/// # use serde_derive::Serialize;
/// # use std::collections::HashMap;
/// #[derive(Serialize)]
/// struct Manifest {
diff --git a/src/spanned.rs b/src/spanned.rs
index fb476ee..cd02c87 100644
--- a/src/spanned.rs
+++ b/src/spanned.rs
@@ -1,8 +1,5 @@
//! ```
-//! #[macro_use]
-//! extern crate serde_derive;
-//!
-//! extern crate toml;
+//! use serde_derive::Deserialize;
//! use toml::Spanned;
//!
//! #[derive(Deserialize)]
@@ -93,7 +90,7 @@ where
{
type Value = Spanned<T>;
- fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+ fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("a TOML spanned")
}
diff --git a/src/tokens.rs b/src/tokens.rs
index 6413ce1..f9d3eb4 100644
--- a/src/tokens.rs
+++ b/src/tokens.rs
@@ -294,8 +294,8 @@ impl<'a> Tokenizer<'a> {
&mut self,
delim: char,
start: usize,
- new_ch: &mut FnMut(
- &mut Tokenizer,
+ new_ch: &mut dyn FnMut(
+ &mut Tokenizer<'_>,
&mut MaybeString,
bool,
usize,
@@ -514,7 +514,7 @@ impl MaybeString {
}
}
- fn into_cow(self, input: &str) -> Cow<str> {
+ fn into_cow(self, input: &str) -> Cow<'_, str> {
match self {
MaybeString::NotEscaped(start) => Cow::Borrowed(&input[start..]),
MaybeString::Owned(s) => Cow::Owned(s),
@@ -665,9 +665,9 @@ mod tests {
#[test]
fn all() {
- fn t(input: &str, expected: &[((usize, usize), Token, &str)]) {
+ fn t(input: &str, expected: &[((usize, usize), Token<'_>, &str)]) {
let mut tokens = Tokenizer::new(input);
- let mut actual: Vec<((usize, usize), Token, &str)> = Vec::new();
+ let mut actual: Vec<((usize, usize), Token<'_>, &str)> = Vec::new();
while let Some((span, token)) = tokens.next().unwrap() {
actual.push((span.into(), token, &input[span.start..span.end]));
}
diff --git a/src/value.rs b/src/value.rs
index dd849e5..00ce703 100644
--- a/src/value.rs
+++ b/src/value.rs
@@ -11,11 +11,10 @@ use serde::de;
use serde::de::IntoDeserializer;
use serde::ser;
-use datetime::{self, DatetimeFromString};
-pub use datetime::{Datetime, DatetimeParseError};
-
-pub use map::Map;
+use crate::datetime::{self, DatetimeFromString};
+pub use crate::datetime::{Datetime, DatetimeParseError};
+pub use crate::map::Map;
/// Representation of a TOML value.
#[derive(PartialEq, Clone, Debug)]
@@ -50,7 +49,7 @@ impl Value {
///
/// This conversion can fail if `T`'s implementation of `Serialize` decides to
/// fail, or if `T` contains a map with non-string keys.
- pub fn try_from<T>(value: T) -> Result<Value, ::ser::Error>
+ pub fn try_from<T>(value: T) -> Result<Value, crate::ser::Error>
where
T: ser::Serialize,
{
@@ -66,7 +65,7 @@ impl Value {
/// something is wrong with the data, for example required struct fields are
/// missing from the TOML map or some number is too big to fit in the expected
/// primitive type.
- pub fn try_into<'de, T>(self) -> Result<T, ::de::Error>
+ pub fn try_into<'de, T>(self) -> Result<T, crate::de::Error>
where
T: de::Deserialize<'de>,
{
@@ -391,17 +390,17 @@ where
}
impl fmt::Display for Value {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- ::ser::to_string(self)
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ crate::ser::to_string(self)
.expect("Unable to represent value as string")
.fmt(f)
}
}
impl FromStr for Value {
- type Err = ::de::Error;
+ type Err = crate::de::Error;
fn from_str(s: &str) -> Result<Value, Self::Err> {
- ::from_str(s)
+ crate::from_str(s)
}
}
@@ -462,7 +461,7 @@ impl<'de> de::Deserialize<'de> for Value {
impl<'de> de::Visitor<'de> for ValueVisitor {
type Value = Value;
- fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+ fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("any valid TOML value")
}
@@ -552,9 +551,9 @@ impl<'de> de::Deserialize<'de> for Value {
}
impl<'de> de::Deserializer<'de> for Value {
- type Error = ::de::Error;
+ type Error = crate::de::Error;
- fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, ::de::Error>
+ fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, crate::de::Error>
where
V: de::Visitor<'de>,
{
@@ -595,7 +594,7 @@ impl<'de> de::Deserializer<'de> for Value {
_name: &str,
_variants: &'static [&'static str],
visitor: V,
- ) -> Result<V::Value, ::de::Error>
+ ) -> Result<V::Value, crate::de::Error>
where
V: de::Visitor<'de>,
{
@@ -610,7 +609,7 @@ impl<'de> de::Deserializer<'de> for Value {
// `None` is interpreted as a missing field so be sure to implement `Some`
// as a present field.
- fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, ::de::Error>
+ fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, crate::de::Error>
where
V: de::Visitor<'de>,
{
@@ -621,14 +620,14 @@ impl<'de> de::Deserializer<'de> for Value {
self,
_name: &'static str,
visitor: V,
- ) -> Result<V::Value, ::de::Error>
+ ) -> Result<V::Value, crate::de::Error>
where
V: de::Visitor<'de>,
{
visitor.visit_newtype_struct(self)
}
- forward_to_deserialize_any! {
+ serde::forward_to_deserialize_any! {
bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit seq
bytes byte_buf map unit_struct tuple_struct struct
tuple ignored_any identifier
@@ -648,9 +647,9 @@ impl SeqDeserializer {
}
impl<'de> de::SeqAccess<'de> for SeqDeserializer {
- type Error = ::de::Error;
+ type Error = crate::de::Error;
- fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, ::de::Error>
+ fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, crate::de::Error>
where
T: de::DeserializeSeed<'de>,
{
@@ -683,9 +682,9 @@ impl MapDeserializer {
}
impl<'de> de::MapAccess<'de> for MapDeserializer {
- type Error = ::de::Error;
+ type Error = crate::de::Error;
- fn next_key_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, ::de::Error>
+ fn next_key_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, crate::de::Error>
where
T: de::DeserializeSeed<'de>,
{
@@ -698,7 +697,7 @@ impl<'de> de::MapAccess<'de> for MapDeserializer {
}
}
- fn next_value_seed<T>(&mut self, seed: T) -> Result<T::Value, ::de::Error>
+ fn next_value_seed<T>(&mut self, seed: T) -> Result<T::Value, crate::de::Error>
where
T: de::DeserializeSeed<'de>,
{
@@ -720,7 +719,7 @@ impl<'de> de::MapAccess<'de> for MapDeserializer {
}
}
-impl<'de> de::IntoDeserializer<'de, ::de::Error> for Value {
+impl<'de> de::IntoDeserializer<'de, crate::de::Error> for Value {
type Deserializer = Self;
fn into_deserializer(self) -> Self {
@@ -732,7 +731,7 @@ struct Serializer;
impl ser::Serializer for Serializer {
type Ok = Value;
- type Error = ::ser::Error;
+ type Error = crate::ser::Error;
type SerializeSeq = SerializeVec;
type SerializeTuple = SerializeVec;
@@ -740,41 +739,41 @@ impl ser::Serializer for Serializer {
type SerializeTupleVariant = SerializeVec;
type SerializeMap = SerializeMap;
type SerializeStruct = SerializeMap;
- type SerializeStructVariant = ser::Impossible<Value, ::ser::Error>;
+ type SerializeStructVariant = ser::Impossible<Value, crate::ser::Error>;
- fn serialize_bool(self, value: bool) -> Result<Value, ::ser::Error> {
+ fn serialize_bool(self, value: bool) -> Result<Value, crate::ser::Error> {
Ok(Value::Boolean(value))
}
- fn serialize_i8(self, value: i8) -> Result<Value, ::ser::Error> {
+ fn serialize_i8(self, value: i8) -> Result<Value, crate::ser::Error> {
self.serialize_i64(value.into())
}
- fn serialize_i16(self, value: i16) -> Result<Value, ::ser::Error> {
+ fn serialize_i16(self, value: i16) -> Result<Value, crate::ser::Error> {
self.serialize_i64(value.into())
}
- fn serialize_i32(self, value: i32) -> Result<Value, ::ser::Error> {
+ fn serialize_i32(self, value: i32) -> Result<Value, crate::ser::Error> {
self.serialize_i64(value.into())
}
- fn serialize_i64(self, value: i64) -> Result<Value, ::ser::Error> {
+ fn serialize_i64(self, value: i64) -> Result<Value, crate::ser::Error> {
Ok(Value::Integer(value.into()))
}
- fn serialize_u8(self, value: u8) -> Result<Value, ::ser::Error> {
+ fn serialize_u8(self, value: u8) -> Result<Value, crate::ser::Error> {
self.serialize_i64(value.into())
}
- fn serialize_u16(self, value: u16) -> Result<Value, ::ser::Error> {
+ fn serialize_u16(self, value: u16) -> Result<Value, crate::ser::Error> {
self.serialize_i64(value.into())
}
- fn serialize_u32(self, value: u32) -> Result<Value, ::ser::Error> {
+ fn serialize_u32(self, value: u32) -> Result<Value, crate::ser::Error> {
self.serialize_i64(value.into())
}
- fn serialize_u64(self, value: u64) -> Result<Value, ::ser::Error> {
+ fn serialize_u64(self, value: u64) -> Result<Value, crate::ser::Error> {
if value <= i64::max_value() as u64 {
self.serialize_i64(value as i64)
} else {
@@ -782,35 +781,35 @@ impl ser::Serializer for Serializer {
}
}
- fn serialize_f32(self, value: f32) -> Result<Value, ::ser::Error> {
+ fn serialize_f32(self, value: f32) -> Result<Value, crate::ser::Error> {
self.serialize_f64(value.into())
}
- fn serialize_f64(self, value: f64) -> Result<Value, ::ser::Error> {
+ fn serialize_f64(self, value: f64) -> Result<Value, crate::ser::Error> {
Ok(Value::Float(value))
}
- fn serialize_char(self, value: char) -> Result<Value, ::ser::Error> {
+ fn serialize_char(self, value: char) -> Result<Value, crate::ser::Error> {
let mut s = String::new();
s.push(value);
self.serialize_str(&s)
}
- fn serialize_str(self, value: &str) -> Result<Value, ::ser::Error> {
+ fn serialize_str(self, value: &str) -> Result<Value, crate::ser::Error> {
Ok(Value::String(value.to_owned()))
}
- fn serialize_bytes(self, value: &[u8]) -> Result<Value, ::ser::Error> {
+ fn serialize_bytes(self, value: &[u8]) -> Result<Value, crate::ser::Error> {
let vec = value.iter().map(|&b| Value::Integer(b.into())).collect();
Ok(Value::Array(vec))
}
- fn serialize_unit(self) -> Result<Value, ::ser::Error> {
- Err(::ser::Error::UnsupportedType)
+ fn serialize_unit(self) -> Result<Value, crate::ser::Error> {
+ Err(crate::ser::Error::UnsupportedType)
}
- fn serialize_unit_struct(self, _name: &'static str) -> Result<Value, ::ser::Error> {
- Err(::ser::Error::UnsupportedType)
+ fn serialize_unit_struct(self, _name: &'static str) -> Result<Value, crate::ser::Error> {
+ Err(crate::ser::Error::UnsupportedType)
}
fn serialize_unit_variant(
@@ -818,7 +817,7 @@ impl ser::Serializer for Serializer {
_name: &'static str,
_variant_index: u32,
_variant: &'static str,
- ) -> Result<Value, ::ser::Error> {
+ ) -> Result<Value, crate::ser::Error> {
self.serialize_str(_variant)
}
@@ -826,7 +825,7 @@ impl ser::Serializer for Serializer {
self,
_name: &'static str,
value: &T,
- ) -> Result<Value, ::ser::Error>
+ ) -> Result<Value, crate::ser::Error>
where
T: ser::Serialize,
{
@@ -839,31 +838,31 @@ impl ser::Serializer for Serializer {
_variant_index: u32,
_variant: &'static str,
_value: &T,
- ) -> Result<Value, ::ser::Error>
+ ) -> Result<Value, crate::ser::Error>
where
T: ser::Serialize,
{
- Err(::ser::Error::UnsupportedType)
+ Err(crate::ser::Error::UnsupportedType)
}
- fn serialize_none(self) -> Result<Value, ::ser::Error> {
- Err(::ser::Error::UnsupportedNone)
+ fn serialize_none(self) -> Result<Value, crate::ser::Error> {
+ Err(crate::ser::Error::UnsupportedNone)
}
- fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Value, ::ser::Error>
+ fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Value, crate::ser::Error>
where
T: ser::Serialize,
{
value.serialize(self)
}
- fn serialize_seq(self, len: Option<usize>) -> Result<Self::SerializeSeq, ::ser::Error> {
+ fn serialize_seq(self, len: Option<usize>) -> Result<Self::SerializeSeq, crate::ser::Error> {
Ok(SerializeVec {
vec: Vec::with_capacity(len.unwrap_or(0)),
})
}
- fn serialize_tuple(self, len: usize) -> Result<Self::SerializeTuple, ::ser::Error> {
+ fn serialize_tuple(self, len: usize) -> Result<Self::SerializeTuple, crate::ser::Error> {
self.serialize_seq(Some(len))
}
@@ -871,7 +870,7 @@ impl ser::Serializer for Serializer {
self,
_name: &'static str,
len: usize,
- ) -> Result<Self::SerializeTupleStruct, ::ser::Error> {
+ ) -> Result<Self::SerializeTupleStruct, crate::ser::Error> {
self.serialize_seq(Some(len))
}
@@ -881,11 +880,11 @@ impl ser::Serializer for Serializer {
_variant_index: u32,
_variant: &'static str,
len: usize,
- ) -> Result<Self::SerializeTupleVariant, ::ser::Error> {
+ ) -> Result<Self::SerializeTupleVariant, crate::ser::Error> {
self.serialize_seq(Some(len))
}
- fn serialize_map(self, _len: Option<usize>) -> Result<Self::SerializeMap, ::ser::Error> {
+ fn serialize_map(self, _len: Option<usize>) -> Result<Self::SerializeMap, crate::ser::Error> {
Ok(SerializeMap {
map: Map::new(),
next_key: None,
@@ -896,7 +895,7 @@ impl ser::Serializer for Serializer {
self,
_name: &'static str,
len: usize,
- ) -> Result<Self::SerializeStruct, ::ser::Error> {
+ ) -> Result<Self::SerializeStruct, crate::ser::Error> {
self.serialize_map(Some(len))
}
@@ -906,8 +905,8 @@ impl ser::Serializer for Serializer {
_variant_index: u32,
_variant: &'static str,
_len: usize,
- ) -> Result<Self::SerializeStructVariant, ::ser::Error> {
- Err(::ser::Error::UnsupportedType)
+ ) -> Result<Self::SerializeStructVariant, crate::ser::Error> {
+ Err(crate::ser::Error::UnsupportedType)
}
}
@@ -922,9 +921,9 @@ struct SerializeMap {
impl ser::SerializeSeq for SerializeVec {
type Ok = Value;
- type Error = ::ser::Error;
+ type Error = crate::ser::Error;
- fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), ::ser::Error>
+ fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), crate::ser::Error>
where
T: ser::Serialize,
{
@@ -932,75 +931,75 @@ impl ser::SerializeSeq for SerializeVec {
Ok(())
}
- fn end(self) -> Result<Value, ::ser::Error> {
+ fn end(self) -> Result<Value, crate::ser::Error> {
Ok(Value::Array(self.vec))
}
}
impl ser::SerializeTuple for SerializeVec {
type Ok = Value;
- type Error = ::ser::Error;
+ type Error = crate::ser::Error;
- fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), ::ser::Error>
+ fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), crate::ser::Error>
where
T: ser::Serialize,
{
ser::SerializeSeq::serialize_element(self, value)
}
- fn end(self) -> Result<Value, ::ser::Error> {
+ fn end(self) -> Result<Value, crate::ser::Error> {
ser::SerializeSeq::end(self)
}
}
impl ser::SerializeTupleStruct for SerializeVec {
type Ok = Value;
- type Error = ::ser::Error;
+ type Error = crate::ser::Error;
- fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), ::ser::Error>
+ fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), crate::ser::Error>
where
T: ser::Serialize,
{
ser::SerializeSeq::serialize_element(self, value)
}
- fn end(self) -> Result<Value, ::ser::Error> {
+ fn end(self) -> Result<Value, crate::ser::Error> {
ser::SerializeSeq::end(self)
}
}
impl ser::SerializeTupleVariant for SerializeVec {
type Ok = Value;
- type Error = ::ser::Error;
+ type Error = crate::ser::Error;
- fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), ::ser::Error>
+ fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), crate::ser::Error>
where
T: ser::Serialize,
{
ser::SerializeSeq::serialize_element(self, value)
}
- fn end(self) -> Result<Value, ::ser::Error> {
+ fn end(self) -> Result<Value, crate::ser::Error> {
ser::SerializeSeq::end(self)
}
}
impl ser::SerializeMap for SerializeMap {
type Ok = Value;
- type Error = ::ser::Error;
+ type Error = crate::ser::Error;
- fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<(), ::ser::Error>
+ fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<(), crate::ser::Error>
where
T: ser::Serialize,
{
match Value::try_from(key)? {
Value::String(s) => self.next_key = Some(s),
- _ => return Err(::ser::Error::KeyNotString),
+ _ => return Err(crate::ser::Error::KeyNotString),
};
Ok(())
}
- fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<(), ::ser::Error>
+ fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<(), crate::ser::Error>
where
T: ser::Serialize,
{
@@ -1010,26 +1009,26 @@ impl ser::SerializeMap for SerializeMap {
Ok(value) => {
self.map.insert(key, value);
}
- Err(::ser::Error::UnsupportedNone) => {}
+ Err(crate::ser::Error::UnsupportedNone) => {}
Err(e) => return Err(e),
}
Ok(())
}
- fn end(self) -> Result<Value, ::ser::Error> {
+ fn end(self) -> Result<Value, crate::ser::Error> {
Ok(Value::Table(self.map))
}
}
impl ser::SerializeStruct for SerializeMap {
type Ok = Value;
- type Error = ::ser::Error;
+ type Error = crate::ser::Error;
fn serialize_field<T: ?Sized>(
&mut self,
key: &'static str,
value: &T,
- ) -> Result<(), ::ser::Error>
+ ) -> Result<(), crate::ser::Error>
where
T: ser::Serialize,
{
@@ -1037,7 +1036,7 @@ impl ser::SerializeStruct for SerializeMap {
ser::SerializeMap::serialize_value(self, value)
}
- fn end(self) -> Result<Value, ::ser::Error> {
+ fn end(self) -> Result<Value, crate::ser::Error> {
ser::SerializeMap::end(self)
}
}
@@ -1060,7 +1059,7 @@ impl<'a, 'de> de::DeserializeSeed<'de> for DatetimeOrTable<'a> {
impl<'a, 'de> de::Visitor<'de> for DatetimeOrTable<'a> {
type Value = bool;
- fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+ fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("a string key")
}