Debian Codegraph @

src/lib.rs

raw symbols SCIP
1 //! Concise, declarative trait implementation macros.
2 //!
3 //! # `#[no_std]`
4 //!
5 //! Where possible, these macros emit `#[no_std]`-compatible code.
6
7 #![cfg_attr(not(docsrs), no_std)]
8 #![cfg_attr(docsrs, feature(doc_auto_cfg))]
9
10 #[cfg(test)]
11 extern crate allocrust-analyzer cargo impl-more 0.3.1 alloc/;
12 #[cfg(test)]
13 extern crate stdrust-analyzer cargo impl-more 0.3.1 std/;
14
15 #[macro_use]
16 mod as_refrust-analyzer cargo impl-more 0.3.1 as_ref/;
17 #[macro_use]
18 mod derefrust-analyzer cargo impl-more 0.3.1 deref/;
19 #[macro_use]
20 mod displayrust-analyzer cargo impl-more 0.3.1 display/;
21 #[macro_use]
22 mod errorrust-analyzer cargo impl-more 0.3.1 error/;
23 #[macro_use]
24 mod fromrust-analyzer cargo impl-more 0.3.1 from/;
25
26 #[cfg(test)]
27 mod testsrust-analyzer cargo impl-more 0.3.1 tests/ {
28 #![allow(dead_code, clippy::from_over_into)]
29
30 use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/::{Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, ToStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString# as _};
31 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::{Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#, DerefMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/DerefMut#};
32
33 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
34 struct Foorust-analyzer cargo impl-more 0.3.1 tests/Foo#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#);
35
36 craterust-analyzer cargo impl-more 0.3.1 crate/::impl_as_refrust-analyzer cargo impl-more 0.3.1 as_ref/impl_as_ref!!(Foorust-analyzer cargo impl-more 0.3.1 tests/Foo# => Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#);
37 craterust-analyzer cargo impl-more 0.3.1 crate/::impl_as_mutrust-analyzer cargo impl-more 0.3.1 as_ref/impl_as_mut!!(Foorust-analyzer cargo impl-more 0.3.1 tests/Foo# => Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#);
38
39 craterust-analyzer cargo impl-more 0.3.1 crate/::impl_derefrust-analyzer cargo impl-more 0.3.1 deref/impl_deref!!(Foorust-analyzer cargo impl-more 0.3.1 tests/Foo# => Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#);
40 craterust-analyzer cargo impl-more 0.3.1 crate/::impl_deref_mutrust-analyzer cargo impl-more 0.3.1 deref/impl_deref_mut!!(Foorust-analyzer cargo impl-more 0.3.1 tests/Foo#);
41
42 static_assertionsrust-analyzer cargo static_assertions 1.1.0 crate/::assert_impl_allrust-analyzer cargo static_assertions 1.1.0 assert_impl/assert_impl_all!!(
43 Foorust-analyzer cargo impl-more 0.3.1 tests/Foo#:
44 // impls
45 AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
46 AsMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsMut#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
47 Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#<Targetrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#Target# = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
48 DerefMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/DerefMut#,
49 );
50
51 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
52 struct Barrust-analyzer cargo impl-more 0.3.1 tests/Bar# {
53 foorust-analyzer cargo impl-more 0.3.1 tests/Bar#foo.: Foorust-analyzer cargo impl-more 0.3.1 tests/Foo#,
54 }
55
56 craterust-analyzer cargo impl-more 0.3.1 crate/::impl_as_refrust-analyzer cargo impl-more 0.3.1 as_ref/impl_as_ref!!(Barrust-analyzer cargo impl-more 0.3.1 tests/Bar# => foorust-analyzer cargo impl-more 0.3.1 tests/Bar#foo.: Foorust-analyzer cargo impl-more 0.3.1 tests/Foo#);
57 craterust-analyzer cargo impl-more 0.3.1 crate/::impl_as_mutrust-analyzer cargo impl-more 0.3.1 as_ref/impl_as_mut!!(Barrust-analyzer cargo impl-more 0.3.1 tests/Bar# => foorust-analyzer cargo impl-more 0.3.1 tests/Bar#foo.: Foorust-analyzer cargo impl-more 0.3.1 tests/Foo#);
58
59 craterust-analyzer cargo impl-more 0.3.1 crate/::impl_derefrust-analyzer cargo impl-more 0.3.1 deref/impl_deref!!(Barrust-analyzer cargo impl-more 0.3.1 tests/Bar# => foorust-analyzer cargo impl-more 0.3.1 tests/Bar#foo.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#);
60 craterust-analyzer cargo impl-more 0.3.1 crate/::impl_deref_mutrust-analyzer cargo impl-more 0.3.1 deref/impl_deref_mut!!(Barrust-analyzer cargo impl-more 0.3.1 tests/Bar# => foorust-analyzer cargo impl-more 0.3.1 tests/Bar#foo.);
61
62 static_assertionsrust-analyzer cargo static_assertions 1.1.0 crate/::assert_impl_allrust-analyzer cargo static_assertions 1.1.0 assert_impl/assert_impl_all!!(
63 Barrust-analyzer cargo impl-more 0.3.1 tests/Bar#:
64 // impls
65 AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<Foorust-analyzer cargo impl-more 0.3.1 tests/Foo#>,
66 AsMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsMut#<Foorust-analyzer cargo impl-more 0.3.1 tests/Foo#>,
67 Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#<Targetrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#Target# = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
68 DerefMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/DerefMut#,
69 );
70
71 #[allow(dead_code)]
72 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
73 fn impl_displayrust-analyzer cargo impl-more 0.3.1 tests/impl_display().() {
74 enum Foorust-analyzer cargo impl-more 0.3.1 tests/Foo# {
75 Barrust-analyzer cargo impl-more 0.3.1 tests/Foo#Bar#,
76 Quxrust-analyzer cargo impl-more 0.3.1 tests/Foo#Qux#,
77 }
78 craterust-analyzer cargo impl-more 0.3.1 crate/::impl_display_enumrust-analyzer cargo impl-more 0.3.1 display/impl_display_enum!!(Foorust-analyzer cargo impl-more 0.3.1 tests/Foo#: Barrust-analyzer cargo impl-more 0.3.1 tests/Foo#Bar# => "bar", Quxrust-analyzer cargo impl-more 0.3.1 tests/Foo#Qux# => "qux");
79 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Foorust-analyzer cargo impl-more 0.3.1 tests/Foo#::Barrust-analyzer cargo impl-more 0.3.1 tests/Foo#Bar#.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "bar");
80 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Foorust-analyzer cargo impl-more 0.3.1 tests/Foo#::Quxrust-analyzer cargo impl-more 0.3.1 tests/Foo#Qux#.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "qux");
81
82 enum FooCommarust-analyzer cargo impl-more 0.3.1 tests/FooComma# {
83 Barrust-analyzer cargo impl-more 0.3.1 tests/FooComma#Bar#,
84 Quxrust-analyzer cargo impl-more 0.3.1 tests/FooComma#Qux#,
85 }
86 craterust-analyzer cargo impl-more 0.3.1 crate/::impl_display_enumrust-analyzer cargo impl-more 0.3.1 display/impl_display_enum!!(FooCommarust-analyzer cargo impl-more 0.3.1 tests/FooComma#: Barrust-analyzer cargo impl-more 0.3.1 tests/FooComma#Bar# => "bar", Quxrust-analyzer cargo impl-more 0.3.1 tests/FooComma#Qux# => "qux",);
87
88 enum FooContentsrust-analyzer cargo impl-more 0.3.1 tests/FooContents# {
89 Barrust-analyzer cargo impl-more 0.3.1 tests/FooContents#Bar#(u64, u64),
90 }
91 craterust-analyzer cargo impl-more 0.3.1 crate/::impl_display_enumrust-analyzer cargo impl-more 0.3.1 display/impl_display_enum!!(FooContentsrust-analyzer cargo impl-more 0.3.1 tests/FooContents#: Barrust-analyzer cargo impl-more 0.3.1 tests/FooContents#Bar# (x, y) => "x: {x}; y: {y}");
92 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(FooContentsrust-analyzer cargo impl-more 0.3.1 tests/FooContents#::Barrust-analyzer cargo impl-more 0.3.1 tests/FooContents#Bar#(4, 2).to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "x: 4; y: 2");
93
94 enum FooContents2rust-analyzer cargo impl-more 0.3.1 tests/FooContents2# {
95 Quxrust-analyzer cargo impl-more 0.3.1 tests/FooContents2#Qux# { msgrust-analyzer cargo impl-more 0.3.1 tests/FooContents2#Qux#msg.: &'static str },
96 }
97 craterust-analyzer cargo impl-more 0.3.1 crate/::impl_display_enumrust-analyzer cargo impl-more 0.3.1 display/impl_display_enum!!(FooContents2rust-analyzer cargo impl-more 0.3.1 tests/FooContents2#: Quxrust-analyzer cargo impl-more 0.3.1 tests/FooContents2#Qux# { msgrust-analyzer cargo impl-more 0.3.1 tests/FooContents2#Qux#msg. } => "msg: {msg}");
98 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(FooContents2rust-analyzer cargo impl-more 0.3.1 tests/FooContents2#::Quxrust-analyzer cargo impl-more 0.3.1 tests/FooContents2#Qux# { msgrust-analyzer cargo impl-more 0.3.1 tests/FooContents2#Qux#msg.: "foo" }.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "msg: foo");
99
100 // not supported yet
101 // enum FooContents3 {
102 // Bar(u64, u64),
103 // Qux { msg: &'static str },
104 // }
105 // impl_display_enum!(FooContents3, Bar (x, y) => "x: {x}; y: {y}", Qux { msg } => "{msg}");
106 // assert_eq!(FooContents3::Bar(4, 2).to_string(), "x: 4; y: 2");
107 // assert_eq!(FooContents3::Qux { msg: "foo" }.to_string(), "x: 4; y: 2");
108 }
109 }