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

Feature-flags should not change code behaviour #6

Open
thomaseizinger opened this issue Aug 3, 2023 · 0 comments
Open

Feature-flags should not change code behaviour #6

thomaseizinger opened this issue Aug 3, 2023 · 0 comments

Comments

@thomaseizinger
Copy link

Hi!

We are interested in using this crate but we'd like to always use the "fast path" because accuracy is not that important for our usecase.

Unfortunately, we are a library crate (libp2p) and if we activate the feature-flag added in #3, then we will change the behaviour for the entire dependency tree which is not something that we want to force onto our users.

I'd like to suggest to consider the following design:

  • Remove the feature-flag
  • Offer two functions in the API (names subject to bike-shedding):
    • accurate_memory_stats
    • fast_memory_stats
  • Both functions return Option<MemoryStats>
  • Users can compose their own fallback behaviour using Option::or

In general, feature flags in cargo should never change code behaviour but only add additional APIs.

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

No branches or pull requests

1 participant