1
1
//! Project/repository utilities.
2
+ #![ allow( clippy:: shadow_reuse, reason = "sometimes its nice" ) ]
3
+ #![ allow( clippy:: unwrap_used, reason = "sometimes its good" ) ]
4
+ #![ allow( clippy:: unwrap_in_result, reason = "sometimes that's what you want" ) ]
2
5
3
- use anyhow:: Context ;
4
- use clap:: Parser ;
6
+ use anyhow:: Context as _ ;
7
+ use clap:: Parser as _ ;
5
8
6
9
/// Our xtask commands.
7
10
#[ derive( Debug , clap:: Parser ) ]
@@ -27,8 +30,11 @@ fn cmd(args: impl IntoIterator<Item = impl AsRef<str>>) -> anyhow::Result<()> {
27
30
Ok ( ( ) )
28
31
}
29
32
33
+ /// Overwrites a toml file's output-dir field, and reverts that on drop.
30
34
struct ShaderCrateTemplateCargoTomlWriter {
35
+ /// Original string
31
36
original_shader_crate_template_str : String ,
37
+ /// Parsed toml table
32
38
table : toml:: Table ,
33
39
}
34
40
@@ -40,8 +46,10 @@ impl Drop for ShaderCrateTemplateCargoTomlWriter {
40
46
}
41
47
42
48
impl ShaderCrateTemplateCargoTomlWriter {
49
+ /// Path to the Cargo.toml
43
50
const PATH : & str = "crates/shader-crate-template/Cargo.toml" ;
44
51
52
+ /// Create a new one
45
53
fn new ( ) -> Self {
46
54
let original_shader_crate_template_str = std:: fs:: read_to_string ( Self :: PATH ) . unwrap ( ) ;
47
55
let table = toml:: from_str :: < toml:: Table > ( & original_shader_crate_template_str) . unwrap ( ) ;
@@ -51,6 +59,7 @@ impl ShaderCrateTemplateCargoTomlWriter {
51
59
}
52
60
}
53
61
62
+ /// Replace the output-dir
54
63
fn replace_output_dir ( & mut self , path : impl AsRef < std:: path:: Path > ) -> anyhow:: Result < ( ) > {
55
64
let package = self
56
65
. table
0 commit comments