Introduce a collections crate w/ deterministic hashmap, hashset in tests
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
co-authored by
Nathan Sobo
parent
5ec003530f
commit
1a91aa8194
@@ -4,19 +4,19 @@ version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[features]
|
||||
test-support = ["rand", "seahash"]
|
||||
test-support = ["rand"]
|
||||
|
||||
[dependencies]
|
||||
clock = { path = "../clock" }
|
||||
collections = { path = "../collections" }
|
||||
sum_tree = { path = "../sum_tree" }
|
||||
anyhow = "1.0.38"
|
||||
arrayvec = "0.7.1"
|
||||
log = "0.4"
|
||||
rand = { version = "0.8.3", optional = true }
|
||||
seahash = { version = "4.1", optional = true }
|
||||
smallvec = { version = "1.6", features = ["union"] }
|
||||
|
||||
[dev-dependencies]
|
||||
collections = { path = "../collections", features = ["test-support"] }
|
||||
gpui = { path = "../gpui", features = ["test-support"] }
|
||||
seahash = "4.1"
|
||||
rand = "0.8.3"
|
||||
|
||||
@@ -12,6 +12,7 @@ mod tests;
|
||||
pub use anchor::*;
|
||||
use anyhow::{anyhow, Result};
|
||||
use clock::ReplicaId;
|
||||
use collections::{HashMap, HashSet};
|
||||
use operation_queue::OperationQueue;
|
||||
pub use point::*;
|
||||
pub use point_utf16::*;
|
||||
@@ -31,31 +32,6 @@ use std::{
|
||||
pub use sum_tree::Bias;
|
||||
use sum_tree::{FilterCursor, SumTree};
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
#[derive(Clone, Default)]
|
||||
pub struct DeterministicState;
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
impl std::hash::BuildHasher for DeterministicState {
|
||||
type Hasher = seahash::SeaHasher;
|
||||
|
||||
fn build_hasher(&self) -> Self::Hasher {
|
||||
seahash::SeaHasher::new()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
type HashMap<K, V> = std::collections::HashMap<K, V, DeterministicState>;
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
type HashSet<T> = std::collections::HashSet<T, DeterministicState>;
|
||||
|
||||
#[cfg(not(any(test, feature = "test-support")))]
|
||||
type HashMap<K, V> = std::collections::HashMap<K, V>;
|
||||
|
||||
#[cfg(not(any(test, feature = "test-support")))]
|
||||
type HashSet<T> = std::collections::HashSet<T>;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Buffer {
|
||||
fragments: SumTree<Fragment>,
|
||||
|
||||
Reference in New Issue
Block a user