Debian Codegraph @

src/node/value.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/;
2 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std 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#;
3
4 /// A value of an attribute.
5 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)]
6 pub struct Valuerust-analyzer cargo svg 0.18.0 node/value/Value#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#);
7
8 impl Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref# for Valuerust-analyzer cargo svg 0.18.0 node/value/Value# {
9 type Targetrust-analyzer cargo svg 0.18.0 node/value/impl#[Value][Deref]Target# = str;
10
11 #[inline]
12 fn derefrust-analyzer cargo svg 0.18.0 node/value/impl#[Value][Deref]deref().(&self) -> &Selfrust-analyzer cargo svg 0.18.0 node/value/impl#[Value][Deref]::Targetrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#Target# {
13 &self.0rust-analyzer cargo svg 0.18.0 node/value/Value#0.
14 }
15 }
16
17 impl fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Valuerust-analyzer cargo svg 0.18.0 node/value/Value# {
18 #[inline]
19 fn fmtrust-analyzer cargo svg 0.18.0 node/value/impl#[Value][Display]fmt().(&self, formatter: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
20 self.0rust-analyzer cargo svg 0.18.0 node/value/Value#0..fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Display]fmt().(formatter)
21 }
22 }
23
24 impl<T> PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#<T> for Valuerust-analyzer cargo svg 0.18.0 node/value/Value#
25 where
26 T: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<str>,
27 {
28 #[inline]
29 fn eqrust-analyzer cargo svg 0.18.0 node/value/impl#[Value][`PartialEq<T>`]eq().(&self, other: &T) -> bool {
30 self.0rust-analyzer cargo svg 0.18.0 node/value/Value#0. rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq().other.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().()
31 }
32 }
33
34 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Valuerust-analyzer cargo svg 0.18.0 node/value/Value#> for Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
35 #[inline]
36 fn fromrust-analyzer cargo svg 0.18.0 node/value/impl#[String][`From<Value>`]from().(Valuerust-analyzer cargo svg 0.18.0 node/value/Value#(inner): Valuerust-analyzer cargo svg 0.18.0 node/value/Value#) -> Selfrust-analyzer cargo svg 0.18.0 node/value/impl#[String][`From<Value>`] {
37 inner
38 }
39 }
40
41 macro_rules! implementrust-analyzer cargo svg 0.18.0 node/value/implement! {
42 ($($primitive:ty,)*) => (
43 $(impl From<$primitive> for Value {
44 #[inline]
45 fn from(inner: $primitive) -> Self {
46 Value(inner.to_string())
47 }
48 })*
49 );
50 }
51
52 implementrust-analyzer cargo svg 0.18.0 node/value/implement!! {
53 i8, i16, i32, i64, isize,
54 u8, u16, u32, u64, usize,
55 f32, f64,
56 Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
57 bool,
58 }
59
60 impl<'l> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<&'l str> for Valuerust-analyzer cargo svg 0.18.0 node/value/Value# {
61 #[inline]
62 fn fromrust-analyzer cargo svg 0.18.0 node/value/impl#[Value][`From<&'l str>`]from().(inner: &'l str) -> Valuerust-analyzer cargo svg 0.18.0 node/value/Value# {
63 Valuerust-analyzer cargo svg 0.18.0 node/value/Value#(inner.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
64 }
65 }
66
67 impl<T> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<T>> for Valuerust-analyzer cargo svg 0.18.0 node/value/Value#
68 where
69 T: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Valuerust-analyzer cargo svg 0.18.0 node/value/Value#>,
70 {
71 fn fromrust-analyzer cargo svg 0.18.0 node/value/impl#[Value][`From<Vec<T>>`]from().(mut inner: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<T>) -> Selfrust-analyzer cargo svg 0.18.0 node/value/impl#[Value][`From<Vec<T>>`] {
72 Valuerust-analyzer cargo svg 0.18.0 node/value/Value#(
73 inner
74 .drainrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]drain().(..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#)
75 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|value| value.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().().0rust-analyzer cargo svg 0.18.0 node/value/Value#0.)
76 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>()
77 .joinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]join().(" "),
78 )
79 }
80 }
81
82 macro_rules! implementrust-analyzer cargo svg 0.18.0 node/value/implement! {
83 (@express $e:expr) => ($e);
84 ($pattern:expr, $(($t:ident, $n:tt)),*) => (
85 impl<$($t),*> From<($($t),*)> for Value
86 where
87 $($t: Into<Value>),*
88 {
89 fn from(inner: ($($t),*)) -> Self {
90 Value(format!($pattern, $(implement!(@express inner.$n).into()),*))
91 }
92 }
93 );
94 }
95
96 implementrust-analyzer cargo svg 0.18.0 node/value/implement!! { "{} {}", (T0, 0), (T1, 1) }
97 implementrust-analyzer cargo svg 0.18.0 node/value/implement!! { "{} {} {} {}", (T0, 0), (T1, 1), (T2, 2), (T3, 3) }
98
99 #[cfg(test)]
100 mod testsrust-analyzer cargo svg 0.18.0 node/value/tests/ {
101 use superrust-analyzer cargo svg 0.18.0 node/value/::Valuerust-analyzer cargo svg 0.18.0 node/value/Value#;
102
103 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
104 fn value_from_vectorrust-analyzer cargo svg 0.18.0 node/value/tests/value_from_vector().() {
105 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo svg 0.18.0 node/value/impl#[String][`From<Value>`]from().(Valuerust-analyzer cargo svg 0.18.0 node/value/Value#::fromrust-analyzer cargo svg 0.18.0 node/value/impl#[Value][`From<Vec<T>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![42, 69])), "42 69");
106 }
107 }