mirror of
https://github.com/serai-dex/serai.git
synced 2024-12-22 11:39:35 +00:00
Add patches for directories-next/option-ext
The rational is detailed in the root Cargo.toml. While I don't personally mind MPL dependencies, even if I don't prefer them (they're allowed in the deny.toml for a reason), I do mind the pointless scope creep and wish to highlight how little it actually used from the crate by re-defining it as the single function. We could also fork directories-next, or directories, and remove the usage of option-ext per https://github.com/dirs-dev/dirs-sys-rs/issues/24, yet that'd be a much larger task than what was done here. In the future, it may be beneficial to submit a PR to wasmtime replacing directories-next with home, a cargo-team maintained library to get the home directory and associated folders. An example migration can be found at https://github.com/harryfei/which-rs/pull/80.
This commit is contained in:
parent
24ea65eae9
commit
8b26a85faa
6 changed files with 53 additions and 21 deletions
18
Cargo.lock
generated
18
Cargo.lock
generated
|
@ -1527,11 +1527,8 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "directories-next"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "339ee130d97a610ea5a5872d2bbb130fdf68884ff09d3028b81bec8a1ac23bbc"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"dirs-sys-next",
|
||||
"directories",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1546,17 +1543,6 @@ dependencies = [
|
|||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs-sys-next"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"redox_users",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "displaydoc"
|
||||
version = "0.2.4"
|
||||
|
@ -4806,8 +4792,6 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
|
|||
[[package]]
|
||||
name = "option-ext"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
|
||||
|
||||
[[package]]
|
||||
name = "overload"
|
||||
|
|
16
Cargo.toml
16
Cargo.toml
|
@ -67,6 +67,9 @@ members = [
|
|||
"tests/coordinator",
|
||||
"tests/full-stack",
|
||||
"tests/reproducible-runtime",
|
||||
|
||||
"patches/option-ext",
|
||||
"patches/directories-next",
|
||||
]
|
||||
|
||||
# Always compile Monero (and a variety of dependencies) with optimizations due
|
||||
|
@ -93,12 +96,17 @@ panic = "unwind"
|
|||
# https://github.com/rust-lang-nursery/lazy-static.rs/issues/201
|
||||
lazy_static = { git = "https://github.com/rust-lang-nursery/lazy-static.rs", rev = "5735630d46572f1e5377c8f2ba0f79d18f53b10c" }
|
||||
|
||||
# subxt *can* pull these off crates.io yet there's no benefit to this
|
||||
sp-core-hashing = { git = "https://github.com/serai-dex/substrate" }
|
||||
sp-std = { git = "https://github.com/serai-dex/substrate" }
|
||||
|
||||
# Needed due to dockertest's usage of `Rc`s when we need `Arc`s
|
||||
dockertest = { git = "https://github.com/kayabaNerve/dockertest-rs", branch = "arc" }
|
||||
|
||||
# directories-next was created because directories was unmaintained
|
||||
# directories-next is now unmaintained while directories is maintained
|
||||
# The directories author pulls in ridiculously pointless crates and prefers
|
||||
# copyleft licenses
|
||||
# The following two patches resolve everything
|
||||
option-ext = { path = "patches/option-ext" }
|
||||
directories-next = { path = "patches/directories-next" }
|
||||
|
||||
[workspace.lints.clippy]
|
||||
unwrap_or_default = "allow"
|
||||
borrow_as_ptr = "deny"
|
||||
|
|
17
patches/directories-next/Cargo.toml
Normal file
17
patches/directories-next/Cargo.toml
Normal file
|
@ -0,0 +1,17 @@
|
|||
[package]
|
||||
name = "directories-next"
|
||||
version = "2.0.0"
|
||||
description = "Patch from directories-next back to directories"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/serai-dex/serai/tree/develop/patches/directories-next"
|
||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||
keywords = []
|
||||
edition = "2021"
|
||||
rust-version = "1.74"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
||||
[dependencies]
|
||||
directories = "5"
|
1
patches/directories-next/src/lib.rs
Normal file
1
patches/directories-next/src/lib.rs
Normal file
|
@ -0,0 +1 @@
|
|||
pub use directories::*;
|
14
patches/option-ext/Cargo.toml
Normal file
14
patches/option-ext/Cargo.toml
Normal file
|
@ -0,0 +1,14 @@
|
|||
[package]
|
||||
name = "option-ext"
|
||||
version = "0.2.0"
|
||||
description = "Non-MPL option-ext with the exactly needed API for directories"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/serai-dex/serai/tree/develop/patches/option-ext"
|
||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||
keywords = []
|
||||
edition = "2021"
|
||||
rust-version = "1.74"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
8
patches/option-ext/src/lib.rs
Normal file
8
patches/option-ext/src/lib.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
pub trait OptionExt<T: PartialEq> {
|
||||
fn contains(&self, x: &T) -> bool;
|
||||
}
|
||||
impl<T: PartialEq> OptionExt<T> for Option<T> {
|
||||
fn contains(&self, x: &T) -> bool {
|
||||
self.as_ref() == Some(x)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue