Skip to content

Tracking Issue for #![feature(ptr_cast_slice)] #149103

@Paladynee

Description

@Paladynee

Feature gate: #![feature(ptr_cast_slice)]

This is a tracking issue for rust-lang/libs-team#693

This feature adds method calls on raw pointers that call into the respective ptr::slice_from_raw_parts{_mut} method for the types *const T, *mut T and NonNull<T> to make using raw pointers more ergonomic in Rust by supporting postfix method chain syntax while creating slices.

Public API

// core::ptr::const_ptr
impl<T> *const T {
    pub const fn cast_slice(self, len: usize) -> *const [T];
}

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

// core::ptr::non_null
impl<T> NonNull<T> {
    pub const fn cast_slice(self, len: usize) -> NonNull<[T]>;
}

Steps / History

(Remember to update the S-tracking-* label when checking boxes.)

Unresolved Questions

  • None yet.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-unimplementedStatus: The feature has not been implemented.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions