File tree 11 files changed +29
-6
lines changed
11 files changed +29
-6
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## [ Unreleased]
4
4
5
+ - Add ` must_use ` attributes to a number of pure public methods.
6
+
5
7
## [ 0.4.0] 2021/12/08
6
8
7
9
- Add ` PartialEq ` and ` Eq ` implementations for ` Process ` .
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ pub struct BuildPlan {
13
13
}
14
14
15
15
impl BuildPlan {
16
+ #[ must_use]
16
17
pub fn new ( ) -> Self {
17
18
Self {
18
19
provides : vec ! [ ] ,
@@ -35,6 +36,7 @@ pub struct BuildPlanBuilder {
35
36
}
36
37
37
38
impl BuildPlanBuilder {
39
+ #[ must_use]
38
40
pub fn new ( ) -> Self {
39
41
Self {
40
42
acc : VecDeque :: new ( ) ,
@@ -53,6 +55,7 @@ impl BuildPlanBuilder {
53
55
self
54
56
}
55
57
58
+ #[ must_use]
56
59
pub fn or ( mut self ) -> Self {
57
60
self . acc
58
61
. push_back ( ( self . current_provides , self . current_requires ) ) ;
@@ -62,6 +65,7 @@ impl BuildPlanBuilder {
62
65
self
63
66
}
64
67
68
+ #[ must_use]
65
69
pub fn build ( self ) -> BuildPlan {
66
70
let mut xyz = self . or ( ) ;
67
71
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ pub struct Launch {
29
29
/// assert!(toml::to_string(&launch_toml).is_ok());
30
30
/// ```
31
31
impl Launch {
32
+ #[ must_use]
32
33
pub fn new ( ) -> Self {
33
34
Self {
34
35
bom : bom:: Bom :: new ( ) ,
@@ -38,6 +39,7 @@ impl Launch {
38
39
}
39
40
}
40
41
42
+ #[ must_use]
41
43
pub fn process ( mut self , process : Process ) -> Self {
42
44
self . processes . push ( process) ;
43
45
self
Original file line number Diff line number Diff line change 7
7
#![ warn( clippy:: pedantic) ]
8
8
// This lint is too noisy and enforces a style that reduces readability in many cases.
9
9
#![ allow( clippy:: module_name_repetitions) ]
10
- // Re-disable pedantic lints that are currently failing, until they are triaged and fixed/wontfixed.
11
- // https://github.com/Malax/libcnb.rs/issues/57
12
- #![ allow( clippy:: must_use_candidate) ]
13
10
14
11
pub mod bom;
15
12
pub mod build;
Original file line number Diff line number Diff line change @@ -146,6 +146,7 @@ pub struct BuildResultBuilder {
146
146
}
147
147
148
148
impl BuildResultBuilder {
149
+ #[ must_use]
149
150
pub fn new ( ) -> Self {
150
151
Self {
151
152
launch : None ,
@@ -166,18 +167,21 @@ impl BuildResultBuilder {
166
167
Ok ( self . build_unwrapped ( ) )
167
168
}
168
169
170
+ #[ must_use]
169
171
pub fn build_unwrapped ( self ) -> BuildResult {
170
172
BuildResult ( InnerBuildResult :: Pass {
171
173
launch : self . launch ,
172
174
store : self . store ,
173
175
} )
174
176
}
175
177
178
+ #[ must_use]
176
179
pub fn launch ( mut self , launch : Launch ) -> Self {
177
180
self . launch = Some ( launch) ;
178
181
self
179
182
}
180
183
184
+ #[ must_use]
181
185
pub fn store ( mut self , store : Store ) -> Self {
182
186
self . store = Some ( store) ;
183
187
self
Original file line number Diff line number Diff line change @@ -46,10 +46,12 @@ pub(crate) enum InnerDetectResult {
46
46
pub struct DetectResultBuilder ;
47
47
48
48
impl DetectResultBuilder {
49
+ #[ must_use]
49
50
pub fn pass ( ) -> PassDetectResultBuilder {
50
51
PassDetectResultBuilder { build_plan : None }
51
52
}
52
53
54
+ #[ must_use]
53
55
pub fn fail ( ) -> FailDetectResultBuilder {
54
56
FailDetectResultBuilder { }
55
57
}
@@ -73,12 +75,14 @@ impl PassDetectResultBuilder {
73
75
Ok ( self . build_unwrapped ( ) )
74
76
}
75
77
78
+ #[ must_use]
76
79
pub fn build_unwrapped ( self ) -> DetectResult {
77
80
DetectResult ( InnerDetectResult :: Pass {
78
81
build_plan : self . build_plan ,
79
82
} )
80
83
}
81
84
85
+ #[ must_use]
82
86
pub fn build_plan ( mut self , build_plan : BuildPlan ) -> Self {
83
87
self . build_plan = Some ( build_plan) ;
84
88
self
@@ -102,6 +106,7 @@ impl FailDetectResultBuilder {
102
106
}
103
107
104
108
#[ allow( clippy:: unused_self) ]
109
+ #[ must_use]
105
110
pub fn build_unwrapped ( self ) -> DetectResult {
106
111
DetectResult ( InnerDetectResult :: Fail )
107
112
}
Original file line number Diff line number Diff line change @@ -38,11 +38,13 @@ impl Env {
38
38
/// variables afterwards will not be reflected in the returned value.
39
39
///
40
40
/// See [`std::env::vars_os`]
41
+ #[ must_use]
41
42
pub fn from_current ( ) -> Self {
42
43
env:: vars_os ( ) . into ( )
43
44
}
44
45
45
46
/// Creates an empty `Env` struct.
47
+ #[ must_use]
46
48
pub fn new ( ) -> Self {
47
49
Self {
48
50
inner : HashMap :: new ( ) ,
@@ -57,15 +59,18 @@ impl Env {
57
59
}
58
60
59
61
/// Returns a cloned value corresponding to the given key.
62
+ #[ must_use]
60
63
pub fn get ( & self , key : impl AsRef < OsStr > ) -> Option < OsString > {
61
64
self . inner . get ( key. as_ref ( ) ) . cloned ( )
62
65
}
63
66
64
67
/// Returns true if the environment contains a value for the specified key.
68
+ #[ must_use]
65
69
pub fn contains_key ( & self , key : impl AsRef < OsStr > ) -> bool {
66
70
self . inner . contains_key ( key. as_ref ( ) )
67
71
}
68
72
73
+ #[ must_use]
69
74
pub fn iter ( & self ) -> std:: collections:: hash_map:: Iter < ' _ , OsString , OsString > {
70
75
self . inner . iter ( )
71
76
}
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ pub struct GenericPlatform {
24
24
}
25
25
26
26
impl GenericPlatform {
27
+ #[ must_use]
27
28
pub fn new ( env : Env ) -> Self {
28
29
Self { env }
29
30
}
Original file line number Diff line number Diff line change @@ -175,13 +175,15 @@ pub struct LayerResultBuilder<M> {
175
175
}
176
176
177
177
impl < M > LayerResultBuilder < M > {
178
+ #[ must_use]
178
179
pub fn new ( metadata : M ) -> Self {
179
180
Self {
180
181
metadata,
181
182
env : None ,
182
183
}
183
184
}
184
185
186
+ #[ must_use]
185
187
pub fn env ( mut self , layer_env : LayerEnv ) -> Self {
186
188
self . env = Some ( layer_env) ;
187
189
self
@@ -199,6 +201,7 @@ impl<M> LayerResultBuilder<M> {
199
201
Ok ( self . build_unwrapped ( ) )
200
202
}
201
203
204
+ #[ must_use]
202
205
pub fn build_unwrapped ( self ) -> LayerResult < M > {
203
206
LayerResult {
204
207
metadata : self . metadata ,
Original file line number Diff line number Diff line change @@ -113,6 +113,7 @@ impl LayerEnv {
113
113
/// let modified_env = layer_env.apply(TargetLifecycle::Build, &env);
114
114
/// assert_eq!(env, modified_env);
115
115
/// ```
116
+ #[ must_use]
116
117
pub fn new ( ) -> Self {
117
118
Self {
118
119
all : LayerEnvDelta :: new ( ) ,
@@ -143,6 +144,7 @@ impl LayerEnv {
143
144
/// assert_eq!(modified_env.get("VAR").unwrap(), "foobar");
144
145
/// assert_eq!(modified_env.get("VAR2").unwrap(), "previous-value");
145
146
/// ```
147
+ #[ must_use]
146
148
pub fn apply ( & self , target : TargetLifecycle , env : & Env ) -> Env {
147
149
let deltas = match target {
148
150
TargetLifecycle :: All => vec ! [ & self . all] ,
@@ -243,6 +245,7 @@ impl LayerEnv {
243
245
/// ),
244
246
/// );
245
247
/// ```
248
+ #[ must_use]
246
249
pub fn chainable_insert (
247
250
mut self ,
248
251
target : TargetLifecycle ,
Original file line number Diff line number Diff line change 11
11
#![ allow( clippy:: module_name_repetitions) ]
12
12
// This lint triggers when both layer_dir and layers_dir are present which are quite common.
13
13
#![ allow( clippy:: similar_names) ]
14
- // Re-disable pedantic lints that are currently failing, until they are triaged and fixed/wontfixed.
15
- // https://github.com/Malax/libcnb.rs/issues/57
16
- #![ allow( clippy:: must_use_candidate) ]
17
14
18
15
pub mod build;
19
16
pub mod detect;
You can’t perform that action at this time.
0 commit comments