Mutex::new() is now const

This commit is contained in:
Folkert 2022-11-09 17:51:43 +01:00
parent 8b53a13f0e
commit e92ceb7282
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
9 changed files with 31 additions and 45 deletions

View file

@ -69,6 +69,14 @@ impl std::fmt::Debug for SmallStringInterner {
}
impl SmallStringInterner {
pub const fn new() -> Self {
Self {
buffer: Vec::new(),
lengths: Vec::new(),
offsets: Vec::new(),
}
}
pub fn with_capacity(capacity: usize) -> Self {
Self {
// guess: the average symbol length is 5

View file

@ -6,14 +6,18 @@ pub struct VecMap<K, V> {
impl<K, V> Default for VecMap<K, V> {
fn default() -> Self {
Self::new()
}
}
impl<K, V> VecMap<K, V> {
pub const fn new() -> Self {
Self {
keys: Vec::new(),
values: Vec::new(),
}
}
}
impl<K, V> VecMap<K, V> {
pub fn len(&self) -> usize {
debug_assert_eq!(self.keys.len(), self.values.len());
self.keys.len()