Skip to content
Myr

lib.rs

This file

Path

serde_core/src/lib.rs

116 lines · 4.0 KiB · Rust

Last changed by

Feature never_type has been stabilized in nightlyDavid Tolnaybefore adoption50b6384

History of this file

Take it

Merge pull request #2608 from osiewicz/extract_serde_coreDavid Tolnaybefore adoption723fcac

lines 1–3why, one step back
1//! Serde is a framework for ***ser***ializing and ***de***serializing Rust data
2//! structures efficiently and generically.3//!

Merge pull request #2964 from dtolnay/serdecoredocDavid Tolnaybefore adoption79f3484

lines 4–5why, one step back
4//! The `serde_core` crate contains Serde's trait definitions with **no support
5//! for #\[derive()\]**.

Merge pull request #2608 from osiewicz/extract_serde_coreDavid Tolnaybefore adoption723fcac

line 6why, one step back
6//!

Merge pull request #2964 from dtolnay/serdecoredocDavid Tolnaybefore adoption79f3484

lines 7–8why, one step back
7//! In crates that derive an implementation of `Serialize` or `Deserialize`, you
8//! must depend on the [`serde`] crate, not `serde_core`.

Merge pull request #2608 from osiewicz/extract_serde_coreDavid Tolnaybefore adoption723fcac

line 9why, one step back
9//!

Merge pull request #2973 from dtolnay/timingsDavid Tolnaybefore adoption85bf29c

lines 10–11why, one step back
10//! [`serde`]: https://crates.io/crates/serde
11//!

Merge pull request #2964 from dtolnay/serdecoredocDavid Tolnaybefore adoption79f3484

lines 12–15why, one step back
12//! In crates that handwrite implementations of Serde traits, or only use them
13//! as trait bounds, depending on `serde_core` is permitted. But `serde`14//! re-exports all of these traits and can be used for this use case too. If in15//! doubt, disregard `serde_core` and always use `serde`.

Merge pull request #2608 from osiewicz/extract_serde_coreDavid Tolnaybefore adoption723fcac

line 16why, one step back
16//!

Merge pull request #2973 from dtolnay/timingsDavid Tolnaybefore adoption85bf29c

lines 17–33why, one step back
17//! Crates that depend on `serde_core` instead of `serde` are able to compile in
18//! parallel with `serde_derive` even when `serde`'s "derive" feature is turned on,19//! as shown in the following build timings.20//!21//! <br>22//!23//! <table>24//! <tr><td align="center">When <code>serde_json</code> depends on <code>serde</code></td></tr>25//! <tr><td><img src="https://github.com/user-attachments/assets/78dc179c-6ab1-4059-928c-1474b0d9d0bb"></td></tr>26//! </table>27//!28//! <br>29//!30//! <table>31//! <tr><td align="center">When <code>serde_json</code> depends on <code>serde_core</code></td></tr>32//! <tr><td><img src="https://github.com/user-attachments/assets/6b6cff5e-3e45-4ac7-9db1-d99ee8b9f5f7"></td></tr>33//! </table>

Merge pull request #2964 from dtolnay/serdecoredocDavid Tolnaybefore adoption79f3484

line 34why, one step back
34

Merge pull request #2608 from osiewicz/extract_serde_coreDavid Tolnaybefore adoption723fcac

lines 35–37why, one step back
35////////////////////////////////////////////////////////////////////////////////
3637// Serde types in rustdoc of other crates get linked to here.

Release 1.0.229David Tolnaybefore adoption7fc3b4c

line 38why, one step back
38#![doc(html_root_url = "https://docs.rs/serde_core/1.0.229")]

Merge pull request #2608 from osiewicz/extract_serde_coreDavid Tolnaybefore adoption723fcac

lines 39–51why, one step back
39// Support using Serde without the standard library!
40#![cfg_attr(not(feature = "std"), no_std)]41// Show which crate feature enables conditionally compiled APIs in documentation.42#![cfg_attr(docsrs, feature(doc_cfg, rustdoc_internals))]43#![cfg_attr(docsrs, allow(internal_features))]44#![allow(unknown_lints, bare_trait_objects, deprecated)]45// Ignored clippy and clippy_pedantic lints46#![allow(47 // clippy bug: https://github.com/rust-lang/rust-clippy/issues/570448 clippy::unnested_or_patterns,49 // clippy bug: https://github.com/rust-lang/rust-clippy/issues/776850 clippy::semicolon_if_nothing_returned,51 // not available in our oldest supported compiler

Update name of empty_enum clippy lintDavid Tolnaybefore adoption56c29b3

line 52why, one step back
52 clippy::empty_enums,

Merge pull request #2608 from osiewicz/extract_serde_coreDavid Tolnaybefore adoption723fcac

lines 53–101why, one step back
53 clippy::type_repetition_in_bounds, // https://github.com/rust-lang/rust-clippy/issues/8772
54 // integer and float ser/de requires these sorts of casts55 clippy::cast_possible_truncation,56 clippy::cast_possible_wrap,57 clippy::cast_precision_loss,58 clippy::cast_sign_loss,59 // things are often more readable this way60 clippy::cast_lossless,61 clippy::module_name_repetitions,62 clippy::single_match_else,63 clippy::type_complexity,64 clippy::use_self,65 clippy::zero_prefixed_literal,66 // correctly used67 clippy::derive_partial_eq_without_eq,68 clippy::enum_glob_use,69 clippy::explicit_auto_deref,70 clippy::incompatible_msrv,71 clippy::let_underscore_untyped,72 clippy::map_err_ignore,73 clippy::new_without_default,74 clippy::result_unit_err,75 clippy::wildcard_imports,76 // not practical77 clippy::needless_pass_by_value,78 clippy::similar_names,79 clippy::too_many_lines,80 // preference81 clippy::doc_markdown,82 clippy::elidable_lifetime_names,83 clippy::needless_lifetimes,84 clippy::unseparated_literal_suffix,85 // false positive86 clippy::needless_doctest_main,87 // noisy88 clippy::missing_errors_doc,89 clippy::must_use_candidate,90)]91// Restrictions92#![deny(clippy::question_mark_used)]93// Rustc lints.94#![deny(missing_docs, unused_imports)]9596////////////////////////////////////////////////////////////////////////////////9798#[cfg(feature = "alloc")]99extern crate alloc;100101#[macro_use]

Merge pull request #2991 from dtolnay/inlinecoredocDavid Tolnaybefore adoption7c58427

lines 102–103why, one step back
102mod crate_root;
103#[macro_use]

Merge pull request #2608 from osiewicz/extract_serde_coreDavid Tolnaybefore adoption723fcac

lines 104–105why, one step back
104mod macros;
105

Merge pull request #2991 from dtolnay/inlinecoredocDavid Tolnaybefore adoption7c58427

line 106why, one step back
106crate_root!();

Merge pull request #2966 from dtolnay/noserdecoreDavid Tolnaybefore adoption35c9631

lines 107–116why, one step back
107
108#[macro_export]109#[doc(hidden)]110macro_rules! __require_serde_not_serde_core {111 () => {112 ::core::compile_error!(113 "Serde derive requires a dependency on the serde crate, not serde_core"114 );115 };116}