David Tolnay c9cab490f7
Resolve multiple_bound_locations clippy lint
warning: bound is defined in more than one place
      --> serde/src/ser/fmt.rs:77:33
       |
    77 |     fn serialize_newtype_struct<T: ?Sized>(self, _name: &'static str, value: &T) -> fmt::Result
       |                                 ^
    78 |     where
    79 |         T: Serialize,
       |         ^
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
       = note: `-W clippy::multiple-bound-locations` implied by `-W clippy::all`
       = help: to override `-W clippy::all` add `#[allow(clippy::multiple_bound_locations)]`

    warning: bound is defined in more than one place
      --> serde/src/ser/fmt.rs:92:23
       |
    92 |     fn serialize_some<T: ?Sized>(self, _value: &T) -> fmt::Result
       |                       ^
    93 |     where
    94 |         T: Serialize,
       |         ^
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/ser/fmt.rs:103:34
        |
    103 |     fn serialize_newtype_variant<T: ?Sized>(
        |                                  ^
    ...
    111 |         T: Serialize,
        |         ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/ser/fmt.rs:164:20
        |
    164 |     fn collect_str<T: ?Sized>(self, value: &T) -> fmt::Result
        |                    ^
    165 |     where
    166 |         T: Display,
        |         ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
      --> serde/src/ser/impossible.rs:75:26
       |
    75 |     fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), Error>
       |                          ^
    76 |     where
    77 |         T: Serialize,
       |         ^
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
      --> serde/src/ser/impossible.rs:95:26
       |
    95 |     fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), Error>
       |                          ^
    96 |     where
    97 |         T: Serialize,
       |         ^
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/ser/impossible.rs:115:24
        |
    115 |     fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Error>
        |                        ^
    116 |     where
    117 |         T: Serialize,
        |         ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/ser/impossible.rs:135:24
        |
    135 |     fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Error>
        |                        ^
    136 |     where
    137 |         T: Serialize,
        |         ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/ser/impossible.rs:155:22
        |
    155 |     fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<(), Error>
        |                      ^
    156 |     where
    157 |         T: Serialize,
        |         ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/ser/impossible.rs:163:24
        |
    163 |     fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<(), Error>
        |                        ^
    164 |     where
    165 |         T: Serialize,
        |         ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/ser/impossible.rs:183:24
        |
    183 |     fn serialize_field<T: ?Sized>(&mut self, key: &'static str, value: &T) -> Result<(), Error>
        |                        ^
    184 |     where
    185 |         T: Serialize,
        |         ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/ser/impossible.rs:204:24
        |
    204 |     fn serialize_field<T: ?Sized>(&mut self, key: &'static str, value: &T) -> Result<(), Error>
        |                        ^
    205 |     where
    206 |         T: Serialize,
        |         ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/ser/mod.rs:799:23
        |
    799 |     fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
        |                       ^
    800 |     where
    801 |         T: Serialize;
        |         ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/ser/mod.rs:894:33
        |
    894 |     fn serialize_newtype_struct<T: ?Sized>(
        |                                 ^
    ...
    900 |         T: Serialize;
        |         ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/ser/mod.rs:928:34
        |
    928 |     fn serialize_newtype_variant<T: ?Sized>(
        |                                  ^
    ...
    936 |         T: Serialize;
        |         ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
        --> serde/src/ser/mod.rs:1349:20
         |
    1349 |     fn collect_str<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
         |                    ^
    1350 |     where
    1351 |         T: Display,
         |         ^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
        --> serde/src/ser/mod.rs:1496:26
         |
    1496 |     fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
         |                          ^
    1497 |     where
    1498 |         T: Serialize;
         |         ^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
        --> serde/src/ser/mod.rs:1596:26
         |
    1596 |     fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
         |                          ^
    1597 |     where
    1598 |         T: Serialize;
         |         ^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
        --> serde/src/ser/mod.rs:1641:24
         |
    1641 |     fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
         |                        ^
    1642 |     where
    1643 |         T: Serialize;
         |         ^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
        --> serde/src/ser/mod.rs:1699:24
         |
    1699 |     fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
         |                        ^
    1700 |     where
    1701 |         T: Serialize;
         |         ^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
        --> serde/src/ser/mod.rs:1770:22
         |
    1770 |     fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<(), Self::Error>
         |                      ^
    1771 |     where
    1772 |         T: Serialize;
         |         ^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
        --> serde/src/ser/mod.rs:1780:24
         |
    1780 |     fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
         |                        ^
    1781 |     where
    1782 |         T: Serialize;
         |         ^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
        --> serde/src/ser/mod.rs:1801:24
         |
    1801 |     fn serialize_entry<K: ?Sized, V: ?Sized>(
         |                        ^
    ...
    1807 |         K: Serialize,
         |         ^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
        --> serde/src/ser/mod.rs:1801:35
         |
    1801 |     fn serialize_entry<K: ?Sized, V: ?Sized>(
         |                                   ^
    ...
    1808 |         V: Serialize,
         |         ^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
        --> serde/src/ser/mod.rs:1859:24
         |
    1859 |     fn serialize_field<T: ?Sized>(
         |                        ^
    ...
    1865 |         T: Serialize;
         |         ^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
        --> serde/src/ser/mod.rs:1925:24
         |
    1925 |     fn serialize_field<T: ?Sized>(
         |                        ^
    ...
    1931 |         T: Serialize;
         |         ^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/private/ser.rs:177:23
        |
    177 |     fn serialize_some<T: ?Sized>(self, _: &T) -> Result<Self::Ok, Self::Error>
        |                       ^
    178 |     where
    179 |         T: Serialize,
        |         ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/private/ser.rs:208:33
        |
    208 |     fn serialize_newtype_struct<T: ?Sized>(
        |                                 ^
    ...
    214 |         T: Serialize,
        |         ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/private/ser.rs:219:34
        |
    219 |     fn serialize_newtype_variant<T: ?Sized>(
        |                                  ^
    ...
    227 |         T: Serialize,
        |         ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/private/ser.rs:367:28
        |
    367 |         fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), M::Error>
        |                            ^
    368 |         where
    369 |             T: Serialize,
        |             ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/private/ser.rs:407:28
        |
    407 |         fn serialize_field<T: ?Sized>(
        |                            ^
    ...
    413 |             T: Serialize,
        |             ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/private/ser.rs:638:27
        |
    638 |         fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Content, E>
        |                           ^
    639 |         where
    640 |             T: Serialize,
        |             ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/private/ser.rs:662:37
        |
    662 |         fn serialize_newtype_struct<T: ?Sized>(
        |                                     ^
    ...
    668 |             T: Serialize,
        |             ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/private/ser.rs:676:38
        |
    676 |         fn serialize_newtype_variant<T: ?Sized>(
        |                                      ^
    ...
    684 |             T: Serialize,
        |             ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/private/ser.rs:785:30
        |
    785 |         fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), E>
        |                              ^
    786 |         where
    787 |             T: Serialize,
        |             ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/private/ser.rs:811:30
        |
    811 |         fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), E>
        |                              ^
    812 |         where
    813 |             T: Serialize,
        |             ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/private/ser.rs:838:28
        |
    838 |         fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), E>
        |                            ^
    839 |         where
    840 |             T: Serialize,
        |             ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/private/ser.rs:867:28
        |
    867 |         fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), E>
        |                            ^
    868 |         where
    869 |             T: Serialize,
        |             ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/private/ser.rs:899:26
        |
    899 |         fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<(), E>
        |                          ^
    900 |         where
    901 |             T: Serialize,
        |             ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/private/ser.rs:908:28
        |
    908 |         fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<(), E>
        |                            ^
    909 |         where
    910 |             T: Serialize,
        |             ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/private/ser.rs:925:28
        |
    925 |         fn serialize_entry<K: ?Sized, V: ?Sized>(&mut self, key: &K, value: &V) -> Result<(), E>
        |                            ^
    926 |         where
    927 |             K: Serialize,
        |             ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/private/ser.rs:925:39
        |
    925 |         fn serialize_entry<K: ?Sized, V: ?Sized>(&mut self, key: &K, value: &V) -> Result<(), E>
        |                                       ^
    ...
    928 |             V: Serialize,
        |             ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/private/ser.rs:950:28
        |
    950 |         fn serialize_field<T: ?Sized>(&mut self, key: &'static str, value: &T) -> Result<(), E>
        |                            ^
    951 |         where
    952 |             T: Serialize,
        |             ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> serde/src/private/ser.rs:979:28
        |
    979 |         fn serialize_field<T: ?Sized>(&mut self, key: &'static str, value: &T) -> Result<(), E>
        |                            ^
    980 |         where
    981 |             T: Serialize,
        |             ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
        --> serde/src/private/ser.rs:1091:23
         |
    1091 |     fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
         |                       ^
    1092 |     where
    1093 |         T: Serialize,
         |         ^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
        --> serde/src/private/ser.rs:1115:33
         |
    1115 |     fn serialize_newtype_struct<T: ?Sized>(
         |                                 ^
    ...
    1121 |         T: Serialize,
         |         ^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
        --> serde/src/private/ser.rs:1126:34
         |
    1126 |     fn serialize_newtype_variant<T: ?Sized>(
         |                                  ^
    ...
    1134 |         T: Serialize,
         |         ^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
        --> serde/src/private/ser.rs:1205:22
         |
    1205 |     fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<(), Self::Error>
         |                      ^
    1206 |     where
    1207 |         T: Serialize,
         |         ^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
        --> serde/src/private/ser.rs:1212:24
         |
    1212 |     fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
         |                        ^
    1213 |     where
    1214 |         T: Serialize,
         |         ^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
        --> serde/src/private/ser.rs:1219:24
         |
    1219 |     fn serialize_entry<K: ?Sized, V: ?Sized>(
         |                        ^
    ...
    1225 |         K: Serialize,
         |         ^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
        --> serde/src/private/ser.rs:1219:35
         |
    1219 |     fn serialize_entry<K: ?Sized, V: ?Sized>(
         |                                   ^
    ...
    1226 |         V: Serialize,
         |         ^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
        --> serde/src/private/ser.rs:1247:24
         |
    1247 |     fn serialize_field<T: ?Sized>(
         |                        ^
    ...
    1253 |         T: Serialize,
         |         ^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
        --> serde/src/private/ser.rs:1292:24
         |
    1292 |     fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
         |                        ^
    1293 |     where
    1294 |         T: Serialize,
         |         ^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
        --> serde/src/private/ser.rs:1338:24
         |
    1338 |     fn serialize_field<T: ?Sized>(
         |                        ^
    ...
    1344 |         T: Serialize,
         |         ^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
2024-02-27 22:45:50 -08:00
2024-02-19 16:22:07 -08:00
2024-01-08 22:22:03 -05:00

Serde Build Status Latest Version serde msrv serde_derive msrv

Serde is a framework for serializing and deserializing Rust data structures efficiently and generically.


You may be looking for:

Serde in action

Click to show Cargo.toml. Run this code in the playground.
[dependencies]

# The core APIs, including the Serialize and Deserialize traits. Always
# required when using Serde. The "derive" feature is only required when
# using #[derive(Serialize, Deserialize)] to make Serde work with structs
# and enums defined in your crate.
serde = { version = "1.0", features = ["derive"] }

# Each data format lives in its own crate; the sample code below uses JSON
# but you may be using a different one.
serde_json = "1.0"

use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug)]
struct Point {
    x: i32,
    y: i32,
}

fn main() {
    let point = Point { x: 1, y: 2 };

    // Convert the Point to a JSON string.
    let serialized = serde_json::to_string(&point).unwrap();

    // Prints serialized = {"x":1,"y":2}
    println!("serialized = {}", serialized);

    // Convert the JSON string back to a Point.
    let deserialized: Point = serde_json::from_str(&serialized).unwrap();

    // Prints deserialized = Point { x: 1, y: 2 }
    println!("deserialized = {:?}", deserialized);
}

Getting help

Serde is one of the most widely used Rust libraries so any place that Rustaceans congregate will be able to help you out. For chat, consider trying the #rust-questions or #rust-beginners channels of the unofficial community Discord (invite: https://discord.gg/rust-lang-community), the #rust-usage or #beginners channels of the official Rust Project Discord (invite: https://discord.gg/rust-lang), or the #general stream in Zulip. For asynchronous, consider the [rust] tag on StackOverflow, the /r/rust subreddit which has a pinned weekly easy questions post, or the Rust Discourse forum. It's acceptable to file a support issue in this repo but they tend not to get as many eyes as any of the above and may get closed without a response after some time.


License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Serde by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Description
Serialization framework for Rust
Readme 13 MiB
Languages
Rust 100%