Allow $env and mutable records to be mutated by = (closes #7110)#7318
Allow $env and mutable records to be mutated by = (closes #7110)#7318kubouch merged 2 commits intonushell:mainfrom
$env and mutable records to be mutated by = (closes #7110)#7318Conversation
|
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"mutvars, $env can be deeply mutated via stuff like$env.PYTHON_IO_ENCODING = utf8or$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
mutvars 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 -- --checkto check standard code formatting (cargo fmt --allapplies these changes)cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collectto check that you're using the standard code stylecargo test --workspaceto 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.