Skip to content

Conversation

@Paladynee
Copy link
Contributor

@Paladynee Paladynee commented Nov 19, 2025

Tracking issue: #149103

This PR implements the method cast_slice that defers to the respective slice_from_raw_parts call for *const T, *mut T and NonNull<T>, and copies over their documentation.

impl<T> *const T {
    pub const fn cast_slice(self, len: usize) -> *const [T];
}
impl<T> *mut T {
    pub const fn cast_slice(self, len: usize) -> *mut [T];
}
impl<T> NonNull<T> {
    pub const fn cast_slice(self, len: usize) -> NonNull<[T]>;
}

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Nov 19, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 19, 2025

r? @ibraheemdev

rustbot has assigned @ibraheemdev.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rust-log-analyzer

This comment has been minimized.

@Paladynee
Copy link
Contributor Author

Paladynee commented Nov 20, 2025

@rustbot label +A-raw-pointers

@rustbot rustbot added the A-raw-pointers Area: raw pointers, MaybeUninit, NonNull label Nov 20, 2025
@jhpratt
Copy link
Member

jhpratt commented Jan 29, 2026

@bors r+ rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 29, 2026

📌 Commit 055cd27 has been approved by jhpratt

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 29, 2026
rust-bors bot pushed a commit that referenced this pull request Jan 29, 2026
Rollup of 12 pull requests

Successful merges:

 - #150474 (Tidy: detect ui tests subdirectory changes so `tests/ui/README.md` stays in sync)
 - #150572 (Improve move error diagnostic for `AsyncFn` closures)
 - #151596 (Fix -Zmir-enable-passes to detect unregistered enum names in declare_passes macro)
 - #151802 (Make `QueryDispatcher::Qcx` an associated type)
 - #149110 (Implement `cast_slice` for raw pointer types)
 - #151559 ([rustdoc] Add a marker to tell users that there are hidden (deprecated) items in the search results)
 - #151665 (Fix contrast ratio for `Since` element in rustdoc dark theme)
 - #151785 (Stabilize feature(push_mut))
 - #151798 (Update `askama` to `0.15.3`)
 - #151800 (Subscribe myself to translation diagnostics)
 - #151804 (Document, sort, and tweak spellcheck entries in `typos.toml`)
 - #151805 (Fix grammar in `env::current_exe()#Security`)
@rust-bors rust-bors bot merged commit 034b53c into rust-lang:main Jan 29, 2026
11 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Jan 29, 2026
rust-timer added a commit that referenced this pull request Jan 29, 2026
Rollup merge of #149110 - Paladynee:acp/ptr_cast_slice, r=jhpratt

Implement `cast_slice` for raw pointer types

Tracking issue: #149103

This PR implements the method `cast_slice` that defers to the respective `slice_from_raw_parts` call for `*const T`, `*mut T` and `NonNull<T>`, and copies over their documentation.
```rust
impl<T> *const T {
    pub const fn cast_slice(self, len: usize) -> *const [T];
}
impl<T> *mut T {
    pub const fn cast_slice(self, len: usize) -> *mut [T];
}
impl<T> NonNull<T> {
    pub const fn cast_slice(self, len: usize) -> NonNull<[T]>;
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-raw-pointers Area: raw pointers, MaybeUninit, NonNull S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants