Skip to content

Commit bf46172

Browse files
committed
Feature-gate the modules
1 parent 8e5e8e9 commit bf46172

File tree

5 files changed

+145
-1
lines changed

5 files changed

+145
-1
lines changed

.github/workflows/ci.yml

+78
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,84 @@ jobs:
7676
profile: minimal
7777
components: clippy
7878

79+
- name: cargo-clippy (convolution)
80+
uses: actions-rs/cargo@v1
81+
with:
82+
command: clippy
83+
args: --workspace --all-targets -- -D warnings
84+
85+
- name: cargo-clippy (convolution)
86+
uses: actions-rs/cargo@v1
87+
with:
88+
command: clippy
89+
args: --workspace --all-targets --no-default-features --features convolution -- -D warnings
90+
91+
- name: cargo-clippy (dsu)
92+
uses: actions-rs/cargo@v1
93+
with:
94+
command: clippy
95+
args: --workspace --all-targets --no-default-features --features dsu -- -D warnings
96+
97+
- name: cargo-clippy (fenwicktree)
98+
uses: actions-rs/cargo@v1
99+
with:
100+
command: clippy
101+
args: --workspace --all-targets --no-default-features --features fenwicktree -- -D warnings
102+
103+
- name: cargo-clippy (lazysegtree)
104+
uses: actions-rs/cargo@v1
105+
with:
106+
command: clippy
107+
args: --workspace --all-targets --no-default-features --features lazysegtree -- -D warnings
108+
109+
- name: cargo-clippy (math)
110+
uses: actions-rs/cargo@v1
111+
with:
112+
command: clippy
113+
args: --workspace --all-targets --no-default-features --features math -- -D warnings
114+
115+
- name: cargo-clippy (maxflow)
116+
uses: actions-rs/cargo@v1
117+
with:
118+
command: clippy
119+
args: --workspace --all-targets --no-default-features --features maxflow -- -D warnings
120+
121+
- name: cargo-clippy (mincostflow)
122+
uses: actions-rs/cargo@v1
123+
with:
124+
command: clippy
125+
args: --workspace --all-targets --no-default-features --features mincostflow -- -D warnings
126+
127+
- name: cargo-clippy (modint)
128+
uses: actions-rs/cargo@v1
129+
with:
130+
command: clippy
131+
args: --workspace --all-targets --no-default-features --features modint -- -D warnings
132+
133+
- name: cargo-clippy (scc)
134+
uses: actions-rs/cargo@v1
135+
with:
136+
command: clippy
137+
args: --workspace --all-targets --no-default-features --features scc -- -D warnings
138+
139+
- name: cargo-clippy (segtree)
140+
uses: actions-rs/cargo@v1
141+
with:
142+
command: clippy
143+
args: --workspace --all-targets --no-default-features --features segtree -- -D warnings
144+
145+
- name: cargo-clippy (string)
146+
uses: actions-rs/cargo@v1
147+
with:
148+
command: clippy
149+
args: --workspace --all-targets --no-default-features --features string -- -D warnings
150+
151+
- name: cargo-clippy (twosat)
152+
uses: actions-rs/cargo@v1
153+
with:
154+
command: clippy
155+
args: --workspace --all-targets --no-default-features --features twosat -- -D warnings
156+
79157
- name: cargo-clippy
80158
uses: actions-rs/cargo@v1
81159
with:

Cargo.toml

+34-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,40 @@ keywords = ["competitive"]
1010
categories = ["algorithms", "data-structures"]
1111
publish = false
1212

13-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
13+
[[example]]
14+
name = "practice2_d_maxflow"
15+
path = "examples/practice2_d_maxflow.rs"
16+
required-features = ["maxflow"]
17+
18+
[[example]]
19+
name = "practice2_j_segment_tree"
20+
path = "examples/practice2_j_segment_tree.rs"
21+
required-features = ["segtree"]
22+
23+
[[example]]
24+
name = "practice2_k_range_affine_range_sum"
25+
path = "examples/practice2_k_range_affine_range_sum.rs"
26+
required-features = ["lazysegtree"]
27+
28+
[[example]]
29+
name = "practice2_l_lazy_segment_tree"
30+
path = "examples/practice2_l_lazy_segment_tree.rs"
31+
required-features = ["lazysegtree"]
32+
33+
[features]
34+
default = ["convolution", "dsu", "fenwicktree", "lazysegtree", "math", "maxflow", "mincostflow", "modint", "scc", "segtree", "string", "twosat"]
35+
convolution = ["modint"]
36+
dsu = []
37+
fenwicktree = []
38+
lazysegtree = ["segtree"]
39+
math = []
40+
maxflow = []
41+
mincostflow = []
42+
modint = []
43+
scc = []
44+
segtree = []
45+
string = []
46+
twosat = []
1447

1548
[dependencies]
1649

src/internal_scc.rs

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ impl SccGraph {
4545
SccGraph { n, edges: vec![] }
4646
}
4747

48+
#[allow(dead_code)]
4849
pub fn num_vertices(&self) -> usize {
4950
self.n
5051
}
@@ -115,6 +116,7 @@ impl SccGraph {
115116
(env.group_num, env.ids)
116117
}
117118

119+
#[allow(dead_code)]
118120
pub fn scc(&self) -> Vec<Vec<usize>> {
119121
let ids = self.scc_ids();
120122
let group_num = ids.0;

src/lib.rs

+29
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,66 @@
1+
#[cfg(feature = "convolution")]
12
pub mod convolution;
3+
#[cfg(feature = "dsu")]
24
pub mod dsu;
5+
#[cfg(feature = "fenwicktree")]
36
pub mod fenwicktree;
7+
#[cfg(feature = "lazysegtree")]
48
pub mod lazysegtree;
9+
#[cfg(feature = "math")]
510
pub mod math;
11+
#[cfg(feature = "maxflow")]
612
pub mod maxflow;
13+
#[cfg(feature = "mincostflow")]
714
pub mod mincostflow;
15+
#[cfg(feature = "modint")]
816
pub mod modint;
17+
#[cfg(feature = "scc")]
918
pub mod scc;
19+
#[cfg(feature = "segtree")]
1020
pub mod segtree;
21+
#[cfg(feature = "string")]
1122
pub mod string;
23+
#[cfg(feature = "twosat")]
1224
pub mod twosat;
1325

26+
#[cfg(any(feature = "convolution", feature = "lazysegtree", feature = "segtree"))]
1427
pub(crate) mod internal_bit;
28+
#[cfg(any(feature = "math", feature = "modint"))]
1529
pub(crate) mod internal_math;
30+
#[cfg(feature = "maxflow")]
1631
pub(crate) mod internal_queue;
32+
#[cfg(any(feature = "scc", feature = "twosat"))]
1733
pub(crate) mod internal_scc;
34+
#[cfg(any(feature = "maxflow", feature = "mincostflow", feature = "segtree"))]
1835
pub(crate) mod internal_type_traits;
1936

37+
#[cfg(feature = "convolution")]
2038
pub use convolution::{convolution, convolution_i64};
39+
#[cfg(feature = "dsu")]
2140
pub use dsu::Dsu;
41+
#[cfg(feature = "fenwicktree")]
2242
pub use fenwicktree::FenwickTree;
43+
#[cfg(feature = "lazysegtree")]
2344
pub use lazysegtree::{LazySegtree, MapMonoid};
45+
#[cfg(feature = "math")]
2446
pub use math::{crt, floor_sum, inv_mod, pow_mod};
47+
#[cfg(feature = "maxflow")]
2548
pub use maxflow::{Edge, MfGraph};
49+
#[cfg(feature = "mincostflow")]
2650
pub use mincostflow::MinCostFlowGraph;
51+
#[cfg(feature = "modint")]
2752
pub use modint::{
2853
Barrett, ButterflyCache, DefaultId, DynamicModInt, Id, Mod1000000007, Mod998244353, ModInt,
2954
ModInt1000000007, ModInt998244353, Modulus, RemEuclidU32, StaticModInt,
3055
};
56+
#[cfg(feature = "scc")]
3157
pub use scc::SccGraph;
58+
#[cfg(feature = "segtree")]
3259
pub use segtree::{Additive, Max, Min, Monoid, Multiplicative, Segtree};
60+
#[cfg(feature = "string")]
3361
pub use string::{
3462
lcp_array, lcp_array_arbitrary, suffix_array, suffix_array_arbitrary, suffix_array_manual,
3563
z_algorithm, z_algorithm_arbitrary,
3664
};
65+
#[cfg(feature = "twosat")]
3766
pub use twosat::TwoSat;

src/modint.rs

+2
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,9 @@ impl Modulus for Mod998244353 {
283283

284284
/// Cache for butterfly operations.
285285
pub struct ButterflyCache<M> {
286+
#[allow(dead_code)]
286287
pub(crate) sum_e: Vec<StaticModInt<M>>,
288+
#[allow(dead_code)]
287289
pub(crate) sum_ie: Vec<StaticModInt<M>>,
288290
}
289291

0 commit comments

Comments
 (0)