diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 849e551..5186ef0 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -59,22 +59,21 @@ jobs: # example_shadow cargo run - name: Run example_shadow - run: cargo run + run: cargo run working-directory: ./example_shadow # build on nightly -# - uses: actions-rs/toolchain@v1 -# with: -# toolchain: nightly -# override: true -# - name: Build on nightly -# run: cargo build --release + - uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + override: true + - name: Build on nightly + run: cargo build --release test: strategy: matrix: -# rust: [stable, beta, nightly] - rust: [stable, beta] + rust: [stable, beta, nightly] runs-on: ubuntu-latest steps: - name: Setup Rust @@ -114,4 +113,4 @@ jobs: - name: Publish shell: bash run: | - cargo publish --token ${{ secrets.CRATES_GITHUB_TOKEN }} \ No newline at end of file + cargo publish --token ${{ secrets.CRATES_GITHUB_TOKEN }} diff --git a/src/date_time.rs b/src/date_time.rs index 518e191..337f974 100644 --- a/src/date_time.rs +++ b/src/date_time.rs @@ -129,7 +129,7 @@ mod tests { .unwrap(); assert!(regex.is_match(&time)); - println!("local now:{}", time); // 2022-07-14 00:40:05 +08:00 + println!("local now:{time}"); // 2022-07-14 00:40:05 +08:00 assert_eq!(time.len(), 26); } diff --git a/src/env.rs b/src/env.rs index 9272f62..daaf73f 100644 --- a/src/env.rs +++ b/src/env.rs @@ -189,7 +189,7 @@ mod dep_source_replace { if tree.trim().is_empty() { tree.push_str(&val); } else { - tree = format!("{}\n{}", tree, val); + tree = format!("{tree}\n{val}"); } } tree @@ -272,7 +272,7 @@ pub fn new_system_env(std_env: &BTreeMap) -> BTreeMap SdResult<()>, { let desc = r#"/// Below code generated by project custom from by build.rs"#; - writeln!(&self.f, "\n{}\n", desc)?; + writeln!(&self.f, "\n{desc}\n")?; f(&self.f)?; Ok(()) } @@ -303,7 +303,7 @@ impl Shadow { let out = { let path = Path::new(out_path.as_str()); if !out_path.ends_with('/') { - path.join(format!("{}/{}", out_path, SHADOW_RS)) + path.join(format!("{out_path}/{SHADOW_RS}")) } else { path.join(SHADOW_RS) } @@ -348,7 +348,7 @@ impl Shadow { pub fn cargo_rerun_if_env_changed(&self) { for k in self.std_env.keys() { - println!("cargo:rerun-if-env-changed={}", k); + println!("cargo:rerun-if-env-changed={k}"); } } @@ -360,7 +360,7 @@ impl Shadow { fn gen_const(&mut self) -> SdResult<()> { for (k, v) in self.map.clone() { - println!("cargo:rerun-if-env-changed={}", k); + println!("cargo:rerun-if-env-changed={k}"); self.write_const(k, v)?; } Ok(()) @@ -374,7 +374,7 @@ impl Shadow { // Create time by:{}"#, DateTime::now().human_format() ); - writeln!(&self.f, "{}\n\n", desc)?; + writeln!(&self.f, "{desc}\n\n")?; Ok(()) } @@ -405,8 +405,8 @@ impl Shadow { ), }; - writeln!(&self.f, "{}", desc)?; - writeln!(&self.f, "{}\n", define)?; + writeln!(&self.f, "{desc}")?; + writeln!(&self.f, "{define}\n")?; Ok(()) } @@ -433,9 +433,9 @@ impl Shadow { } } }; - writeln!(&self.f, "{}\n", ver_fn)?; - writeln!(&self.f, "{}\n", clap_ver_fn)?; - writeln!(&self.f, "{}\n", clap_long_ver_fn)?; + writeln!(&self.f, "{ver_fn}\n")?; + writeln!(&self.f, "{clap_ver_fn}\n")?; + writeln!(&self.f, "{clap_long_ver_fn}\n")?; Ok(vec![BUILD_CONST_VERSION, BUILD_CONST_CLAP_LONG_VERSION]) } @@ -459,11 +459,10 @@ impl Shadow { "/// print build in method\n\ #[allow(dead_code)]\n\ pub fn print_build_in() {\ - {{}}\ -}\n", - print_val, + {{print_val}}\ + }\n", ); - writeln!(&self.f, "{}", everything_define)?; + writeln!(&self.f, "{everything_define}")?; Ok(()) } @@ -480,14 +479,14 @@ mod tests { let shadow = fs::read_to_string("./shadow.rs")?; assert!(!shadow.is_empty()); assert!(shadow.lines().count() > 0); - println!("{}", shadow); + println!("{shadow}"); Ok(()) } #[test] fn test_env() { for (k, v) in std::env::vars() { - println!("K:{},V:{}", k, v); + println!("K:{k},V:{v}"); } } }