serde_attributes/
lib.rs

1//! Serde Attributes. [Extract from](https://github.com/serde-rs/serde/blob/v1.0.127/serde_derive/src/internals/attr.rs#L290)
2//!
3#![cfg_attr(not(feature = "std"), no_std)]
4
5extern crate alloc;
6
7#[cfg(feature = "attr-alias")]
8pub mod alias;
9#[cfg(feature = "attr-alias")]
10pub use alias::Alias;
11
12#[cfg(feature = "attr-rename")]
13pub mod rename;
14#[cfg(feature = "attr-rename")]
15pub use rename::{Rename, RenameIndependent};
16
17#[cfg(feature = "attr-rename-all")]
18pub mod rename_all;
19#[cfg(feature = "attr-rename-all")]
20pub use rename_all::{RenameAll, RenameAllIndependent};
21
22pub mod symbol {
23    //
24    #[derive(Copy, Clone)]
25    pub struct Symbol(pub &'static str);
26
27    /// [Ref](https://github.com/serde-rs/serde/blob/v1.0.228/serde_derive/src/internals/symbol.rs#L30)
28    #[cfg(any(feature = "attr-rename", feature = "attr-rename-all"))]
29    pub const SERIALIZE: Symbol = Symbol("serialize");
30    #[cfg(any(feature = "attr-rename", feature = "attr-rename-all"))]
31    /// [Ref](https://github.com/serde-rs/serde/blob/v1.0.228/serde_derive/src/internals/symbol.rs#L14)
32    pub const DESERIALIZE: Symbol = Symbol("deserialize");
33
34    #[cfg(feature = "with-syn")]
35    impl PartialEq<Symbol> for syn::Ident {
36        fn eq(&self, word: &Symbol) -> bool {
37            self == word.0
38        }
39    }
40
41    #[cfg(feature = "with-syn")]
42    impl PartialEq<Symbol> for &syn::Ident {
43        fn eq(&self, word: &Symbol) -> bool {
44            *self == word.0
45        }
46    }
47
48    #[cfg(feature = "with-syn")]
49    impl PartialEq<Symbol> for syn::Path {
50        fn eq(&self, word: &Symbol) -> bool {
51            self.is_ident(word.0)
52        }
53    }
54
55    #[cfg(feature = "with-syn")]
56    impl PartialEq<Symbol> for &syn::Path {
57        fn eq(&self, word: &Symbol) -> bool {
58            self.is_ident(word.0)
59        }
60    }
61
62    impl core::fmt::Display for Symbol {
63        fn fmt(&self, formatter: &mut core::fmt::Formatter) -> core::fmt::Result {
64            formatter.write_str(self.0)
65        }
66    }
67}
68
69pub use symbol::Symbol;