Add a const constructor for KeyData (#106)

This commit is contained in:
MOZGIII 2020-10-17 17:38:13 +03:00 committed by GitHub
parent 9d3d8770e4
commit ff4795e74f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -36,6 +36,16 @@ impl KeyData {
}
}
/// Creates a `KeyData` from a static name.
///
/// This function is const, so it can be used in a static context.
pub const fn from_static_name(name: &'static str) -> Self {
Self {
name: ScopedString::Borrowed(name),
labels: Vec::new(),
}
}
/// Name of this key.
pub fn name(&self) -> &ScopedString {
&self.name