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

Remove Env::default #1837

Merged
merged 1 commit into from
Aug 4, 2021
Merged

Remove Env::default #1837

merged 1 commit into from
Aug 4, 2021

Conversation

cmyr
Copy link
Member

@cmyr cmyr commented Jun 28, 2021

This was a bit of a footgun; it would always configure localization
resources, which doesn't make sense if we want to use an Env as just a
bag of key/values in some contexts.

Specifically, we may want to do this for #1658.

The fix is a two-parter:

  • the LocalizationManager owned by the env is now optional, although
    it is expected to exist for the root env. The framework makes sure this
    is the case.
  • There is a new Env::empty method that creates a new empty
    environment, with no localization resources. This is suitable for the
    'specifying overrides' case.

@arthmis if you're still interested in finishing up #1658, then I would merge this as is, but if that is in doubt I would probably remove the empty() method since it isn't really useful anywhere else I can think of?

@arthmis
Copy link
Collaborator

arthmis commented Jul 2, 2021

Yes this sounds good. Give me a few days to get back into this.

@@ -186,5 +186,5 @@ pub(crate) fn add_to_env(env: Env) -> Env {

#[deprecated(since = "0.7.0", note = "use Env::default() instead")]
Copy link

@pleshevskiy pleshevskiy Jul 2, 2021

Choose a reason for hiding this comment

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

I think we should also change the note to following

#[deprecated(since = "0.7.0", note = "use Env::with_default_i10n() instead")]

or Env::empty(). You know best :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we just remove this? I don't think this is a popular function 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

agree, there's no good way to use this right now.

Copy link
Collaborator

@PoignardAzur PoignardAzur left a comment

Choose a reason for hiding this comment

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

LGTM. Merging in a few days unless someone objects.

This was a bit of a footgun; it would always configure localization
resources, which doesn't make sense if we want to use an `Env` as just a
bag of key/values in some contexts.

Specifically, we may want to do this for #1658.

The fix is a two-parter:

- the `LocalizationManager` owned by the env is now optional, although
  it is expected to exist for the root env. The framework makes sure this
  is the case.
- There is a new `Env::empty` method that creates a new empty
  environment, with no localization resources. This is suitable for the
  'specifying overrides' case.
@cmyr cmyr merged commit 4eaffd2 into master Aug 4, 2021
@cmyr cmyr deleted the tweak-env-api branch August 4, 2021 16:50
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.

5 participants