1
Fork 0

Add Mutability::mutably_str

This commit is contained in:
Maybe Waffle 2022-11-23 19:13:57 +00:00
parent e51cd6e822
commit 4439f1f6a6
3 changed files with 17 additions and 22 deletions

View file

@ -804,6 +804,14 @@ impl Mutability {
}
}
/// Returns `""` (empty string) or `"mutably "` depending on the mutability.
pub fn mutably_str(self) -> &'static str {
match self {
Mutability::Not => "",
Mutability::Mut => "mutably ",
}
}
/// Return `true` if self is mutable
pub fn is_mut(self) -> bool {
matches!(self, Self::Mut)