1#![cfg_attr(feature = "nightly", allow(internal_features))]
10#![cfg_attr(feature = "nightly", feature(never_type))]
11#![cfg_attr(feature = "nightly", feature(rustc_attrs))]
12#[cfg(feature = "nightly")]
15use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_NoContext};
16
17pub mod visit;
18
19#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)]
22#[cfg_attr(
23 feature = "nightly",
24 derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
25)]
26pub enum Movability {
27 Static,
29 Movable,
31}
32
33#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)]
34#[cfg_attr(
35 feature = "nightly",
36 derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
37)]
38pub enum Mutability {
39 Not,
41 Mut,
42}
43
44impl Mutability {
45 pub fn invert(self) -> Self {
46 match self {
47 Mutability::Mut => Mutability::Not,
48 Mutability::Not => Mutability::Mut,
49 }
50 }
51
52 pub fn prefix_str(self) -> &'static str {
54 match self {
55 Mutability::Mut => "mut ",
56 Mutability::Not => "",
57 }
58 }
59
60 pub fn ref_prefix_str(self) -> &'static str {
62 match self {
63 Mutability::Not => "&",
64 Mutability::Mut => "&mut ",
65 }
66 }
67
68 pub fn ptr_str(self) -> &'static str {
70 match self {
71 Mutability::Not => "const",
72 Mutability::Mut => "mut",
73 }
74 }
75
76 pub fn mutably_str(self) -> &'static str {
78 match self {
79 Mutability::Not => "",
80 Mutability::Mut => "mutably ",
81 }
82 }
83
84 pub fn is_mut(self) -> bool {
86 matches!(self, Self::Mut)
87 }
88
89 pub fn is_not(self) -> bool {
91 matches!(self, Self::Not)
92 }
93}
94
95#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)]
96#[cfg_attr(
97 feature = "nightly",
98 derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
99)]
100pub enum Pinnedness {
101 Not,
102 Pinned,
103}