mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 11:52:19 +00:00
Mutex::new() is now const
This commit is contained in:
parent
8b53a13f0e
commit
e92ceb7282
9 changed files with 31 additions and 45 deletions
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue