chore: Make some of the deps of gpui optional (#16986)
Minor bookkeeping, that takes down dep count of gpui from 454 to 430 for me. Release Notes: - N/A
This commit is contained in:
parent
22a791d9c7
commit
4ec1f29df0
4 changed files with 53 additions and 46 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -4916,7 +4916,6 @@ dependencies = [
|
||||||
"sum_tree",
|
"sum_tree",
|
||||||
"taffy",
|
"taffy",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"time",
|
|
||||||
"unicode-segmentation",
|
"unicode-segmentation",
|
||||||
"usvg",
|
"usvg",
|
||||||
"util",
|
"util",
|
||||||
|
|
|
@ -15,6 +15,7 @@ default = []
|
||||||
test-support = [
|
test-support = [
|
||||||
"backtrace",
|
"backtrace",
|
||||||
"collections/test-support",
|
"collections/test-support",
|
||||||
|
"rand",
|
||||||
"util/test-support",
|
"util/test-support",
|
||||||
"http_client/test-support",
|
"http_client/test-support",
|
||||||
]
|
]
|
||||||
|
@ -36,7 +37,6 @@ bytemuck = { version = "1", optional = true }
|
||||||
collections.workspace = true
|
collections.workspace = true
|
||||||
ctor.workspace = true
|
ctor.workspace = true
|
||||||
derive_more.workspace = true
|
derive_more.workspace = true
|
||||||
env_logger.workspace = true
|
|
||||||
etagere = "0.2"
|
etagere = "0.2"
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
gpui_macros.workspace = true
|
gpui_macros.workspace = true
|
||||||
|
@ -50,7 +50,7 @@ parking = "2.0.0"
|
||||||
parking_lot.workspace = true
|
parking_lot.workspace = true
|
||||||
postage.workspace = true
|
postage.workspace = true
|
||||||
profiling.workspace = true
|
profiling.workspace = true
|
||||||
rand.workspace = true
|
rand = { optional = true, workspace = true}
|
||||||
raw-window-handle = "0.6"
|
raw-window-handle = "0.6"
|
||||||
refineable.workspace = true
|
refineable.workspace = true
|
||||||
resvg = { version = "0.41.0", default-features = false }
|
resvg = { version = "0.41.0", default-features = false }
|
||||||
|
@ -68,7 +68,6 @@ strum.workspace = true
|
||||||
sum_tree.workspace = true
|
sum_tree.workspace = true
|
||||||
taffy = "0.4.3"
|
taffy = "0.4.3"
|
||||||
thiserror.workspace = true
|
thiserror.workspace = true
|
||||||
time.workspace = true
|
|
||||||
util.workspace = true
|
util.workspace = true
|
||||||
uuid.workspace = true
|
uuid.workspace = true
|
||||||
waker-fn = "1.2.0"
|
waker-fn = "1.2.0"
|
||||||
|
@ -76,6 +75,8 @@ waker-fn = "1.2.0"
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
backtrace = "0.3"
|
backtrace = "0.3"
|
||||||
collections = { workspace = true, features = ["test-support"] }
|
collections = { workspace = true, features = ["test-support"] }
|
||||||
|
env_logger.workspace = true
|
||||||
|
rand.workspace = true
|
||||||
util = { workspace = true, features = ["test-support"] }
|
util = { workspace = true, features = ["test-support"] }
|
||||||
http_client = { workspace = true, features = ["test-support"] }
|
http_client = { workspace = true, features = ["test-support"] }
|
||||||
unicode-segmentation.workspace = true
|
unicode-segmentation.workspace = true
|
||||||
|
@ -152,6 +153,7 @@ font-kit = { git = "https://github.com/zed-industries/font-kit", rev = "40391b7"
|
||||||
x11-clipboard = "0.9.2"
|
x11-clipboard = "0.9.2"
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
|
rand.workspace = true
|
||||||
windows.workspace = true
|
windows.workspace = true
|
||||||
windows-core = "0.58"
|
windows-core = "0.58"
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ path = "src/util.rs"
|
||||||
doctest = true
|
doctest = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
test-support = ["tempfile", "git2"]
|
test-support = ["tempfile", "git2", "rand"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
|
@ -23,7 +23,7 @@ futures.workspace = true
|
||||||
git2 = { workspace = true, optional = true }
|
git2 = { workspace = true, optional = true }
|
||||||
globset.workspace = true
|
globset.workspace = true
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
rand.workspace = true
|
rand = {workspace = true, optional = true}
|
||||||
regex.workspace = true
|
regex.workspace = true
|
||||||
rust-embed.workspace = true
|
rust-embed.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
|
@ -40,3 +40,4 @@ tendril = "0.4.3"
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
git2.workspace = true
|
git2.workspace = true
|
||||||
tempfile.workspace = true
|
tempfile.workspace = true
|
||||||
|
rand.workspace = true
|
||||||
|
|
|
@ -6,7 +6,7 @@ pub mod serde;
|
||||||
pub mod test;
|
pub mod test;
|
||||||
|
|
||||||
use futures::Future;
|
use futures::Future;
|
||||||
use rand::{seq::SliceRandom, Rng};
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use std::sync::OnceLock;
|
use std::sync::OnceLock;
|
||||||
use std::{
|
use std::{
|
||||||
|
@ -517,54 +517,59 @@ pub fn defer<F: FnOnce()>(f: F) -> Deferred<F> {
|
||||||
Deferred(Some(f))
|
Deferred(Some(f))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct RandomCharIter<T: Rng> {
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
rng: T,
|
mod rng {
|
||||||
simple_text: bool,
|
use rand::{seq::SliceRandom, Rng};
|
||||||
}
|
pub struct RandomCharIter<T: Rng> {
|
||||||
|
rng: T,
|
||||||
|
simple_text: bool,
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: Rng> RandomCharIter<T> {
|
impl<T: Rng> RandomCharIter<T> {
|
||||||
pub fn new(rng: T) -> Self {
|
pub fn new(rng: T) -> Self {
|
||||||
Self {
|
Self {
|
||||||
rng,
|
rng,
|
||||||
simple_text: std::env::var("SIMPLE_TEXT").map_or(false, |v| !v.is_empty()),
|
simple_text: std::env::var("SIMPLE_TEXT").map_or(false, |v| !v.is_empty()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_simple_text(mut self) -> Self {
|
||||||
|
self.simple_text = true;
|
||||||
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_simple_text(mut self) -> Self {
|
impl<T: Rng> Iterator for RandomCharIter<T> {
|
||||||
self.simple_text = true;
|
type Item = char;
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: Rng> Iterator for RandomCharIter<T> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
type Item = char;
|
if self.simple_text {
|
||||||
|
return if self.rng.gen_range(0..100) < 5 {
|
||||||
|
Some('\n')
|
||||||
|
} else {
|
||||||
|
Some(self.rng.gen_range(b'a'..b'z' + 1).into())
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
match self.rng.gen_range(0..100) {
|
||||||
if self.simple_text {
|
// whitespace
|
||||||
return if self.rng.gen_range(0..100) < 5 {
|
0..=19 => [' ', '\n', '\r', '\t'].choose(&mut self.rng).copied(),
|
||||||
Some('\n')
|
// two-byte greek letters
|
||||||
} else {
|
20..=32 => char::from_u32(self.rng.gen_range(('α' as u32)..('ω' as u32 + 1))),
|
||||||
Some(self.rng.gen_range(b'a'..b'z' + 1).into())
|
// // three-byte characters
|
||||||
};
|
33..=45 => ['✋', '✅', '❌', '❎', '⭐']
|
||||||
}
|
.choose(&mut self.rng)
|
||||||
|
.copied(),
|
||||||
match self.rng.gen_range(0..100) {
|
// // four-byte characters
|
||||||
// whitespace
|
46..=58 => ['🍐', '🏀', '🍗', '🎉'].choose(&mut self.rng).copied(),
|
||||||
0..=19 => [' ', '\n', '\r', '\t'].choose(&mut self.rng).copied(),
|
// ascii letters
|
||||||
// two-byte greek letters
|
_ => Some(self.rng.gen_range(b'a'..b'z' + 1).into()),
|
||||||
20..=32 => char::from_u32(self.rng.gen_range(('α' as u32)..('ω' as u32 + 1))),
|
}
|
||||||
// // three-byte characters
|
|
||||||
33..=45 => ['✋', '✅', '❌', '❎', '⭐']
|
|
||||||
.choose(&mut self.rng)
|
|
||||||
.copied(),
|
|
||||||
// // four-byte characters
|
|
||||||
46..=58 => ['🍐', '🏀', '🍗', '🎉'].choose(&mut self.rng).copied(),
|
|
||||||
// ascii letters
|
|
||||||
_ => Some(self.rng.gen_range(b'a'..b'z' + 1).into()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
|
pub use rng::RandomCharIter;
|
||||||
/// Get an embedded file as a string.
|
/// Get an embedded file as a string.
|
||||||
pub fn asset_str<A: rust_embed::RustEmbed>(path: &str) -> Cow<'static, str> {
|
pub fn asset_str<A: rust_embed::RustEmbed>(path: &str) -> Cow<'static, str> {
|
||||||
match A::get(path).unwrap().data {
|
match A::get(path).unwrap().data {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue