spo_rhai/types/
var_def.rs1#[cfg(feature = "no_std")]
4use std::prelude::v1::*;
5
6#[derive(Debug, Clone, Hash)]
8pub struct VarDefInfo<'a> {
9 #[deprecated(
15 since = "1.16.0",
16 note = "`VarDefInfo` fields will be private in the next major version. Use `name()` instead."
17 )]
18 pub name: &'a str,
19 #[deprecated(
25 since = "1.16.0",
26 note = "`VarDefInfo` fields will be private in the next major version. Use `is_const()` instead."
27 )]
28 pub is_const: bool,
29 #[deprecated(
35 since = "1.16.0",
36 note = "`VarDefInfo` fields will be private in the next major version. Use `nesting_level()` instead."
37 )]
38 pub nesting_level: usize,
39 #[deprecated(
45 since = "1.16.0",
46 note = "`VarDefInfo` fields will be private in the next major version. Use `will_shadow_other_variables()` instead."
47 )]
48 pub will_shadow: bool,
49}
50
51#[allow(deprecated)]
52impl<'a> VarDefInfo<'a> {
53 #[inline(always)]
55 #[must_use]
56 pub(crate) const fn new(
57 name: &'a str,
58 is_const: bool,
59 nesting_level: usize,
60 will_shadow: bool,
61 ) -> Self {
62 Self {
63 name,
64 is_const,
65 nesting_level,
66 will_shadow,
67 }
68 }
69 #[inline(always)]
71 #[must_use]
72 pub const fn name(&self) -> &str {
73 self.name
74 }
75 #[inline(always)]
77 #[must_use]
78 pub const fn is_const(&self) -> bool {
79 self.is_const
80 }
81 #[inline(always)]
83 #[must_use]
84 pub const fn nesting_level(&self) -> usize {
85 self.nesting_level
86 }
87 #[inline(always)]
89 #[must_use]
90 pub const fn is_global_level(&self) -> bool {
91 self.nesting_level == 0
92 }
93 #[inline(always)]
95 #[must_use]
96 pub const fn will_shadow_other_variables(&self) -> bool {
97 self.will_shadow
98 }
99}