lsd icon indicating copy to clipboard operation
lsd copied to clipboard

refactor: use default attribute for enum

Open TeamTamoad opened this issue 2 years ago • 6 comments

Use the new feature from Rust 1.62 to make code more concise https://blog.rust-lang.org/2022/06/30/Rust-1.62.0.html#default-enum-variants

Since we just bump the CICD to Rust 1.62.1, I think it's ok to use the new feature from Rust.


TODO

  • [x] Use cargo fmt
  • [ ] Add necessary tests
  • [ ] Add changelog entry
  • [ ] Update default config/theme in README (if applicable)
  • [ ] Update man page at lsd/doc/lsd.md (if applicable)

TeamTamoad avatar Aug 07 '22 13:08 TeamTamoad

Codecov Report

Merging #714 (bcf917b) into master (b5ad6d0) will decrease coverage by 0.03%. The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #714      +/-   ##
==========================================
- Coverage   88.36%   88.32%   -0.04%     
==========================================
  Files          41       41              
  Lines        4546     4505      -41     
==========================================
- Hits         4017     3979      -38     
+ Misses        529      526       -3     
Impacted Files Coverage Δ
src/flags/color.rs 93.49% <ø> (-0.21%) :arrow_down:
src/flags/date.rs 95.68% <ø> (-0.07%) :arrow_down:
src/flags/display.rs 100.00% <ø> (ø)
src/flags/hyperlink.rs 95.65% <ø> (-0.13%) :arrow_down:
src/flags/icons.rs 96.40% <ø> (-0.11%) :arrow_down:
src/flags/layout.rs 100.00% <ø> (ø)
src/flags/permission.rs 94.91% <ø> (-0.17%) :arrow_down:
src/flags/size.rs 98.41% <ø> (-0.05%) :arrow_down:
src/flags/sorting.rs 98.13% <ø> (-0.06%) :arrow_down:
... and 6 more

:mega: Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

codecov-commenter avatar Aug 07 '22 13:08 codecov-commenter

That is a neat language addition. I was not aware of it. Could you bump up the min version in build script as well. https://github.com/Peltoche/lsd/blob/1553aafe9db589dfe9d0385a2111127060af8db8/build.rs#L21

meain avatar Aug 07 '22 14:08 meain

If 1.62.0 would do, lets keep it as that.

meain avatar Aug 07 '22 16:08 meain

If 1.62.0 would do, lets keep it as that.

Could you clarify to me why it's better to use 1.62.0? I prefer 1.62.1 because

  • It matches the Rust version in CICD.
  • Some regression and vulnerability have been fixed in 1.62.1. https://blog.rust-lang.org/2022/07/19/Rust-1.62.1.html

TeamTamoad avatar Aug 08 '22 16:08 TeamTamoad

Could you clarify to me why it's better to use 1.62.0?

The min version we support is not as important as it is not a lib but I would still like to let folks compile with the minimum version they can compile lsd with.

By setting this, we are in no way restricting us or users from using 1.62.1 and taking advantage of the new fixes but just mentioning that they won't be able to compile it with anything lower than 1.62.0. Keeping it as low as possible (while updating it to meet our needs), we enable them to compile lsd even if they happen to not have the latest and greatest rust version(eg: their package manager might not have the latest version).

It matches the Rust version in CICD.

Now that you mention it, I think we should switch it to 1.62.0 (if clippy is still happy) as well to make sure it compiles with that version as we change things.

meain avatar Aug 08 '22 16:08 meain

@meain Thank you so much for explaining it to me. I'll reduce the MSRV in both places. I'm curious about when we release the lsd. What is the version of Rust that is used to compile code?

TeamTamoad avatar Aug 12 '22 08:08 TeamTamoad

It will use the latest stable version IIRC. You can check the build step for the CI run of previous release.

meain avatar Aug 12 '22 12:08 meain