Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split into a workspace #22

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ jobs:
uses: taiki-e/install-action@cargo-hack

- name: Build crate
run: cargo hack --feature-powerset build --all-targets --verbose
run: cargo hack --workspace --feature-powerset build --all-targets --verbose

- name: Test crate
run: cargo hack --feature-powerset test --verbose
run: cargo hack --workspace --feature-powerset test --verbose

minimal-versions:
runs-on: ubuntu-latest
Expand All @@ -91,10 +91,10 @@ jobs:
tool: cargo-hack,cargo-minimal-versions

- name: Build crate
run: cargo minimal-versions --direct --feature-powerset build --all-targets --verbose
run: cargo minimal-versions --direct --workspace --feature-powerset build --all-targets --verbose

- name: Test crate
run: cargo minimal-versions --direct --feature-powerset test --verbose
run: cargo minimal-versions --direct --workspace --feature-powerset test --verbose

coverage:
# This is separate from the main tests because cargo-llvm-cov doesn't run
Expand All @@ -120,7 +120,7 @@ jobs:
tool: cargo-llvm-cov

- name: Test with coverage
run: cargo llvm-cov --all-features --lcov --output-path lcov.info
run: cargo llvm-cov --workspace --all-features --lcov --output-path lcov.info

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
Expand Down Expand Up @@ -149,13 +149,13 @@ jobs:
uses: taiki-e/install-action@cargo-hack

- name: Check code (no tests)
run: cargo hack --feature-powerset clippy -- -Dwarnings
run: cargo hack --workspace --feature-powerset clippy -- -Dwarnings

- name: Check code (including tests)
run: cargo hack --feature-powerset clippy --all-targets -- -Dwarnings
run: cargo hack --workspace --feature-powerset clippy --all-targets -- -Dwarnings

- name: Check formatting
run: cargo fmt --check
run: cargo fmt --all --check

docs:
runs-on: ubuntu-latest
Expand All @@ -173,7 +173,7 @@ jobs:
uses: Swatinem/rust-cache@v2

- name: Check docs
run: cargo doc --no-deps --all-features
run: cargo doc --workspace --no-deps --all-features
env:
RUSTDOCFLAGS: -Dwarnings

Expand Down
44 changes: 18 additions & 26 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,39 +1,31 @@
[package]
name = "rswodlib"
version = "0.1.0"
[workspace]
members = ["crates/*"]
resolver = "2"

[workspace.package]
edition = "2021"
description = "Assorted Rust utility functions"
authors = ["John Thorvald Wodder II <[email protected]>"]
repository = "https://github.com/jwodder/rswodlib"
license = "MIT"
exclude = ["/.*"]
publish = false

[package]
name = "rswodlib"
edition.workspace = true
description = "Assorted Rust utility functions"
authors.workspace = true
repository.workspace = true
license.workspace = true

[dependencies]
automod = "1.0.8"
bstr = { version = "1.4.0", default-features = false, features = ["std"] }
futures-util = { version = "0.3.29", default-features = false, features = ["std"], optional = true }
log = "0.4.20"
num-traits = "0.2.15"
pin-project-lite = { version = "0.2.11", optional = true }
shell-words = "1.1.0"
thiserror = "2.0.0"
tokio = { version = "1.29.0", features = ["sync", "time"], optional = true }
tokio-util = { version = "0.7.10", features = ["rt"], optional = true }

[dev-dependencies]
assert_fs = "1.0.13"
predicates = "3.0.3"
rstest = { version = "0.23.0", default-features = false }
tokio = { version = "1.29.0", features = ["io-util", "macros", "rt"] }

[build-dependencies]
rustc_version = "0.4.1"

[features]
tokio = ["dep:futures-util", "dep:pin-project-lite", "dep:tokio", "dep:tokio-util"]
[lints]
workspace = true

[lints.rust]
[workspace.lints.rust]
# Lint groups:
future_incompatible = { level = "deny", priority = -1 }
refining_impl_trait = { level = "deny", priority = -1 }
Expand Down Expand Up @@ -112,7 +104,7 @@ unused_comparisons = "deny"
useless_ptr_null_checks = "deny"
while_true = "deny"

[lints.rustdoc]
[workspace.lints.rustdoc]
bare_urls = "deny"
broken_intra_doc_links = "deny"
invalid_codeblock_attributes = "deny"
Expand All @@ -122,7 +114,7 @@ private_intra_doc_links = "deny"
redundant_explicit_links = "deny"
unescaped_backticks = "deny"

[lints.clippy]
[workspace.lints.clippy]
# Deny all warn-by-default lints:
all = { level = "deny", priority = -1 }

Expand Down
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@
[![codecov.io](https://codecov.io/gh/jwodder/rswodlib/branch/master/graph/badge.svg)](https://codecov.io/gh/jwodder/rswodlib)
[![MIT License](https://img.shields.io/github/license/jwodder/rswodlib.svg)](https://opensource.org/licenses/MIT)

`rswodlib` is a personal Rust library containing various useful (and often
reused) functions & functionalities that aren't quite worthy of packages of
their own. It is not meant to be installed; instead, if you see anything you
like in it, you are encouraged to copy & paste, subject to the MIT license.
`rswodlib` is a personal collection of [Rust](https://www.rust-lang.org)
functions & functionalities that, though useful and often reused, aren't quite
worthy of published packages of their own. It is not meant to be installed;
instead, if you see anything you like in it, you are encouraged to copy &
paste, subject to the MIT license.

The project is laid out as a [workspace][] in which the root package contains
only code with no (non-test) dependencies beyond `std` (and [`automod`][], for
convenience) while the other packages (all located in `crates/`) require one or
more third-party dependencies each.

[workspace]: https://doc.rust-lang.org/cargo/reference/workspaces.html
[`automod`]: https://crates.io/crates/automod
16 changes: 16 additions & 0 deletions crates/generic-num/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "rswodlib-generic-num"
edition.workspace = true
#description = ...
authors.workspace = true
repository.workspace = true
license.workspace = true

[dependencies]
num-traits = "0.2.15"

[dev-dependencies]
rstest = { version = "0.23.0", default-features = false }

[lints]
workspace = true
File renamed without changes.
4 changes: 4 additions & 0 deletions crates/generic-num/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mod gcd;
mod modinverse;
pub use crate::gcd::*;
pub use crate::modinverse::*;
File renamed without changes.
15 changes: 15 additions & 0 deletions crates/loggedcmd/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "rswodlib-loggedcmd"
edition.workspace = true
#description = ...
authors.workspace = true
repository.workspace = true
license.workspace = true

[dependencies]
log = "0.4.20"
shell-words = "1.1.0"
thiserror = "2.0.0"

[lints]
workspace = true
File renamed without changes.
15 changes: 15 additions & 0 deletions crates/partition/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "rswodlib-partition"
edition.workspace = true
#description = ...
authors.workspace = true
repository.workspace = true
license.workspace = true

[dependencies]

[build-dependencies]
rustc_version = "0.4.1"

[lints]
workspace = true
1 change: 1 addition & 0 deletions crates/partition/LICENSE
File renamed without changes.
3 changes: 2 additions & 1 deletion src/strings/partition.rs → crates/partition/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![cfg(nightly)]
#![feature(pattern)]
// Requires the "pattern" feature on nightly
// - `#![feature(pattern)]` must be enabled in the root module
// - rswodlib is configured to only make use of nightly features when actually
Expand All @@ -13,7 +14,7 @@ use std::str::pattern::Pattern;
/// # Example
///
/// ```
/// # use rswodlib::strings::partition::partition;
/// # use rswodlib_partition::partition;
/// assert_eq!(partition("abc.123-xyz", ['-', '.']), Some(("abc", ".", "123-xyz")));
/// assert_eq!(partition("abc_123_xyz", ['-', '.']), None);
/// ```
Expand Down
19 changes: 19 additions & 0 deletions crates/runcmd/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "rswodlib-runcmd"
edition.workspace = true
#description = ...
authors.workspace = true
repository.workspace = true
license.workspace = true

[dependencies]
bstr = { version = "1.4.0", default-features = false, features = ["std"] }
rswodlib = { path = "../.." }
thiserror = "2.0.0"

[dev-dependencies]
assert_fs = "1.0.13"
predicates = "3.0.3"

[lints]
workspace = true
5 changes: 2 additions & 3 deletions src/cmd/runcmd.rs → crates/runcmd/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::strings::trim_string::trim_string;
use bstr::ByteVec; // into_string_lossy()
use rswodlib::strings::trim_string::trim_string;
use std::ffi::OsStr;
use std::process::{Command, ExitStatus, Stdio};
use std::str;
Expand Down Expand Up @@ -112,8 +112,7 @@ mod tests {
#[cfg(unix)]
mod unix {
use super::*;
use assert_fs::prelude::*;
use assert_fs::NamedTempFile;
use assert_fs::{prelude::*, NamedTempFile};
use predicates::prelude::*;

#[test]
Expand Down
15 changes: 15 additions & 0 deletions crates/tokio-btn/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "rswodlib-tokio-btn"
edition.workspace = true
#description = ...
authors.workspace = true
repository.workspace = true
license.workspace = true

[dependencies]
futures-util = { version = "0.3.29", default-features = false, features = ["std"] }
tokio = { version = "1.29.0", features = ["sync"] }
tokio-util = { version = "0.7.10", features = ["rt"] }

[lints]
workspace = true
File renamed without changes.
14 changes: 14 additions & 0 deletions crates/tokio-buffered-tasks/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "rswodlib-tokio-buffered-tasks"
edition.workspace = true
#description = ...
authors.workspace = true
repository.workspace = true
license.workspace = true

[dependencies]
futures-util = { version = "0.3.29", default-features = false, features = ["std"] }
tokio = { version = "1.29.0", features = ["rt", "sync"] }

[lints]
workspace = true
File renamed without changes.
15 changes: 15 additions & 0 deletions crates/tokio-lsg/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "rswodlib-tokio-lsg"
edition.workspace = true
#description = ...
authors.workspace = true
repository.workspace = true
license.workspace = true

[dependencies]
futures-util = { version = "0.3.29", default-features = false, features = ["std"] }
tokio = { version = "1.29.0", features = ["sync"] }
tokio-util = { version = "0.7.10", features = ["rt"] }

[lints]
workspace = true
File renamed without changes.
18 changes: 18 additions & 0 deletions crates/tokio-received-stream/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "rswodlib-tokio-received-stream"
edition.workspace = true
#description = ...
authors.workspace = true
repository.workspace = true
license.workspace = true

[dependencies]
futures-util = { version = "0.3.29", default-features = false, features = ["std"] }
pin-project-lite = "0.2.11"
tokio = { version = "1.29.0", features = ["sync"] }

[dev-dependencies]
tokio = { version = "1.29.0", features = ["io-util", "macros", "rt"] }

[lints]
workspace = true
File renamed without changes.
18 changes: 18 additions & 0 deletions crates/tokio-shutdown-group/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "rswodlib-tokio-shutdown-group"
edition.workspace = true
#description = ...
authors.workspace = true
repository.workspace = true
license.workspace = true

[dependencies]
tokio = { version = "1.29.0", features = ["time"] }
tokio-util = { version = "0.7.10", features = ["rt"] }

[dev-dependencies]
futures-util = { version = "0.3.29", default-features = false, features = ["std"] }
tokio = { version = "1.29.0", features = ["macros", "rt"] }

[lints]
workspace = true
File renamed without changes.
17 changes: 17 additions & 0 deletions crates/unique-stream/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "rswodlib-unique-stream"
edition.workspace = true
#description = ...
authors.workspace = true
repository.workspace = true
license.workspace = true

[dependencies]
futures-util = { version = "0.3.29", default-features = false, features = ["std"] }
pin-project-lite = "0.2.11"

[dev-dependencies]
tokio = { version = "1.29.0", features = ["macros", "rt"] }

[lints]
workspace = true
File renamed without changes.
1 change: 0 additions & 1 deletion src/cmd.rs

This file was deleted.

2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
#![cfg_attr(nightly, feature(pattern))]

automod::dir!(pub "src");
3 changes: 0 additions & 3 deletions src/tokio.rs

This file was deleted.

Loading