Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the flate2 dependency optional #157

Merged
merged 2 commits into from Nov 26, 2021
Merged

Make the flate2 dependency optional #157

merged 2 commits into from Nov 26, 2021

Conversation

eminence
Copy link
Owner

CC #156

let file = FileWrapper::open(PROC_CONFIG_GZ)?;
let decoder = GzDecoder::new(file);
Box::new(BufReader::new(decoder))
let reader: Box<dyn BufRead> = if Path::new(PROC_CONFIG_GZ).exists() && cfg!(feature = "flate2") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think && cfg!(feature = "flate2") is useless

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if cfg!(feature = "flate2") == false, block would not execute

if cfg!(feature = "flate2") == true, block would execute flate2::read::GzDecoder

so the cfg(not(...flate2 block may never execute

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if cfg!(feature = "flate2") == false, block would not execute

if cfg!(feature = "flate2") == true, block would execute flate2::read::GzDecoder

so the cfg(not(...flate2 block may never execute

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the #[cfg(not(feature = "flate2"))] block is unreachable, but is needed to typecheck

@pymongo
Copy link
Contributor

pymongo commented Nov 10, 2021

Other prosible conditional compile logic:

  1. if feature = "flate2" disable, not compile the pub fn kernel_config function, and all unittest relative it add cfg(feature="flate2") attr
  2. like procfs::boot_times(), in chrono feature return Datetime while not chrono feature return i64, I think kernel_config not flate2 feature can return bytes, and flate2 feature return HashMap

@pymongo
Copy link
Contributor

pymongo commented Nov 11, 2021

This PR looks good to me, I can remove the flate2 dependency and speed up my project compile

@eminence
Copy link
Owner Author

This is a breaking change, since anyone using procfs with default-features = false will see an incompatible change in behavior for the kernel_config function. This is unfortunate, but I'm going to live with it. We'll put a big notice in the release notes about this breaking change. I'll also looked many crates that depend on procfs and use default-features = false, and none use the kernel_config function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants