-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Allow $env
and mutable records to be mutated by =
(closes #7110)
#7318
Conversation
really love the idea of being able to change config settings so easily. |
I like the idea but I don't like special-casing |
But |
From the language point of view |
|
@webbedspace We discussed this a bit and it seems like we could support adding new record fields with Also, it would need tests. |
661d9d6
to
33af9c8
Compare
OK, I've now done all that. Note that I had to do a number of non-trivial tweaks in order to make mutable lists like |
I'm not sure how others will feel about these changes but I'm loving playing in this PR. I love how it makes changing things so easy. The only thing that took me by surprise was the ability to mutate the next indexed element. Example:
I mean, I could live with this and I think it's kind of cool, but it took me by surprise. |
That's what I had to do to take the concept of "mutating via insert", which already exists for records, and "make it make sense" for lists. In Javascript, of course, you can just do EDIT: Forgot to mention, this is also how |
$env
to be mutated by =
as if it was mutable (closes #7110)$env
and mutable variables to be mutated by =
(closes #7110)
$env
and mutable variables to be mutated by =
(closes #7110)$env
and mutable records to be mutated by =
(closes #7110)
OK, looks good, let's try it. Thanks! |
Description
Closes #7110.
Note that unlike "real"mut
vars, $env can be deeply mutated via stuff like$env.PYTHON_IO_ENCODING = utf8
or$env.config.history.max_size = 2000
. So, it's a slightly awkward special case, arguably justifiable because of what $env represents (the environment variables of your system, which is essentially "outside" normal Nushell regulations).EDIT: Now allows all
mut
vars to be deeply mutated using=
, on request.User-Facing Changes
See above.
Tests + Formatting
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --check
to check standard code formatting (cargo fmt --all
applies these changes)cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
to check that you're using the standard code stylecargo test --workspace
to check that all tests passAfter Submitting
If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.