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 reference conversions from ArrayOps #26

Merged
merged 1 commit into from
Jan 26, 2024

Conversation

tarcieri
Copy link
Member

Removes the following methods:

  • as_core_array
  • as_mut_core_array
  • ref_from_core_array
  • ref_mut_from_core_array

These can now all be accomplished using AsRef::as_ref or From/Into

Removes the following methods:

- as_core_array
- as_mut_core_array
- ref_from_core_array
- ref_mut_from_core_array

These can now all be accomplished using `AsRef::as_ref` or `From`/`Into`
@tarcieri
Copy link
Member Author

I tested this against a few repos and we don't seem to be using it anywhere

Copy link
Member

@newpavlov newpavlov left a comment

Choose a reason for hiding this comment

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

It's probably worth to explicitly describe with examples in the crate docs that the crate supports conversion in both directions of values and references using AsRef/From/Into traits.

@tarcieri
Copy link
Member Author

Oh definitely, I've been planning on adding a lot more documentation of that nature.

@tarcieri tarcieri merged commit e4c6bff into master Jan 26, 2024
14 checks passed
@tarcieri tarcieri deleted the remove-ref-conversions-from-arrayops branch January 26, 2024 21:31
tarcieri added a commit that referenced this pull request Jan 27, 2024
After #24, #25, and #26, these traits don't really need to exist and
have largely been replaced by safe type conversions with appropriate
bounds.

In lieu of `ArrayOps<T, N>` we instead can use
`U: ArraySize<ArrayType<T> = [T; N]>>` as a bound, which albeit a bit
more verbose concretely describes the inner type of `Array` to the
compiler.

The `cast_slice_(to|from)_core(_mut)` methods previously defined on the
trait have been preserved, but as static methods of `Array`, making the
change largely a drop in replacement. Places where they were being
called as e.g. `ArrayOps::cast_slice_to_core` just need to be called as
`Array::cast_slice_to_core` instead.
tarcieri added a commit that referenced this pull request Jan 27, 2024
After #24, #25, and #26, these traits don't really need to exist and
have largely been replaced by safe type conversions with appropriate
bounds.

In lieu of `ArrayOps<T, N>` we instead can use
`U: ArraySize<ArrayType<T> = [T; N]>>` as a bound, which albeit a bit
more verbose concretely describes the inner type of `Array` to the
compiler.

The `cast_slice_(to|from)_core(_mut)` methods previously defined on the
trait have been preserved, but as static methods of `Array`, making the
change largely a drop in replacement. Places where they were being
called as e.g. `ArrayOps::cast_slice_to_core` just need to be called as
`Array::cast_slice_to_core` instead.
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.

2 participants