nushell/crates
Ian Manske 1c49ca503a
Name the Value conversion functions more clearly (#11851)
# Description
This PR renames the conversion functions on `Value` to be more consistent.
It follows the Rust [API guidelines](https://rust-lang.github.io/api-guidelines/naming.html#ad-hoc-conversions-follow-as_-to_-into_-conventions-c-conv) for ad-hoc conversions.
The conversion functions on `Value` now come in a few forms:
- `coerce_{type}` takes a `&Value` and attempts to convert the value to
`type` (e.g., `i64` are converted to `f64`). This is the old behavior of
some of the `as_{type}` functions -- these functions have simply been
renamed to better reflect what they do.
- The new `as_{type}` functions take a `&Value` and returns an `Ok`
result only if the value is of `type` (no conversion is attempted). The
returned value will be borrowed if `type` is non-`Copy`, otherwise an
owned value is returned.
- `into_{type}` exists for non-`Copy` types, but otherwise does not
attempt conversion just like `as_type`. It takes an owned `Value` and
always returns an owned result.
- `coerce_into_{type}` has the same relationship with `coerce_{type}` as
`into_{type}` does with `as_{type}`.
- `to_{kind}_string`: conversion to different string formats (debug,
abbreviated, etc.). Only two of the old string conversion functions were
removed, the rest have been renamed only.
- `to_{type}`: other conversion functions. Currently, only `to_path`
exists. (And `to_string` through `Display`.)

This table summaries the above:
| Form | Cost | Input Ownership | Output Ownership | Converts `Value`
case/`type` |
| ---------------------------- | ----- | --------------- |
---------------- | -------- |
| `as_{type}` | Cheap | Borrowed | Borrowed/Owned | No |
| `into_{type}` | Cheap | Owned | Owned | No |
| `coerce_{type}` | Cheap | Borrowed | Borrowed/Owned | Yes |
| `coerce_into_{type}` | Cheap | Owned | Owned | Yes |
| `to_{kind}_string` | Expensive | Borrowed | Owned | Yes |
| `to_{type}` | Expensive | Borrowed | Owned | Yes |

# User-Facing Changes
Breaking API change for `Value` in `nu-protocol` which is exposed as
part of the plugin API.
2024-02-17 18:14:16 +00:00
..
nu_plugin_custom_values bump to dev release of nushell 0.90.2 (#11793) 2024-02-07 16:26:03 -06:00
nu_plugin_example bump to dev release of nushell 0.90.2 (#11793) 2024-02-07 16:26:03 -06:00
nu_plugin_formats Name the Value conversion functions more clearly (#11851) 2024-02-17 18:14:16 +00:00
nu_plugin_gstat Name the Value conversion functions more clearly (#11851) 2024-02-17 18:14:16 +00:00
nu_plugin_inc Name the Value conversion functions more clearly (#11851) 2024-02-17 18:14:16 +00:00
nu_plugin_python remove vectorize_over_list from python plugin (#9905) 2023-08-03 16:46:48 +02:00
nu_plugin_query Name the Value conversion functions more clearly (#11851) 2024-02-17 18:14:16 +00:00
nu-cli Name the Value conversion functions more clearly (#11851) 2024-02-17 18:14:16 +00:00
nu-cmd-base Name the Value conversion functions more clearly (#11851) 2024-02-17 18:14:16 +00:00
nu-cmd-dataframe Name the Value conversion functions more clearly (#11851) 2024-02-17 18:14:16 +00:00
nu-cmd-extra Name the Value conversion functions more clearly (#11851) 2024-02-17 18:14:16 +00:00
nu-cmd-lang Prevent duplicate keys for lazy make (#11808) 2024-02-14 00:00:52 +00:00
nu-color-config Name the Value conversion functions more clearly (#11851) 2024-02-17 18:14:16 +00:00
nu-command Name the Value conversion functions more clearly (#11851) 2024-02-17 18:14:16 +00:00
nu-engine Name the Value conversion functions more clearly (#11851) 2024-02-17 18:14:16 +00:00
nu-explore Name the Value conversion functions more clearly (#11851) 2024-02-17 18:14:16 +00:00
nu-glob bump to dev release of nushell 0.90.2 (#11793) 2024-02-07 16:26:03 -06:00
nu-json bump to dev release of nushell 0.90.2 (#11793) 2024-02-07 16:26:03 -06:00
nu-lsp Bump miette from 5.10.0 to 7.0.0 (#11788) 2024-02-07 19:26:18 -06:00
nu-parser Name the Value conversion functions more clearly (#11851) 2024-02-17 18:14:16 +00:00
nu-path bump to dev release of nushell 0.90.2 (#11793) 2024-02-07 16:26:03 -06:00
nu-plugin bump to dev release of nushell 0.90.2 (#11793) 2024-02-07 16:26:03 -06:00
nu-pretty-hex bump to dev release of nushell 0.90.2 (#11793) 2024-02-07 16:26:03 -06:00
nu-protocol Name the Value conversion functions more clearly (#11851) 2024-02-17 18:14:16 +00:00
nu-std Bump miette from 5.10.0 to 7.0.0 (#11788) 2024-02-07 19:26:18 -06:00
nu-system bump to dev release of nushell 0.90.2 (#11793) 2024-02-07 16:26:03 -06:00
nu-table Name the Value conversion functions more clearly (#11851) 2024-02-17 18:14:16 +00:00
nu-term-grid bump to dev release of nushell 0.90.2 (#11793) 2024-02-07 16:26:03 -06:00
nu-test-support Bump which from 5.0.0 to 6.0.0 (#11832) 2024-02-15 14:43:56 +00:00
nu-utils update default_config with new defaults (#11856) 2024-02-14 13:01:27 -06:00
README.md Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00

Nushell core libraries and plugins

These sub-crates form both the foundation for Nu and a set of plugins which extend Nu with additional functionality.

Foundational libraries are split into two kinds of crates:

  • Core crates - those crates that work together to build the Nushell language engine
  • Support crates - a set of crates that support the engine with additional features like JSON support, ANSI support, and more.

Plugins are likewise also split into two types:

  • Core plugins - plugins that provide part of the default experience of Nu, including access to the system properties, processes, and web-connectivity features.
  • Extra plugins - these plugins run a wide range of different capabilities like working with different file types, charting, viewing binary data, and more.