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

Tracking issue for the `cast` method of raw pointers #60602

Closed
SimonSapin opened this issue May 7, 2019 · 4 comments

Comments

Projects
None yet
2 participants
@SimonSapin
Copy link
Contributor

commented May 7, 2019

#60601 adds:

impl<T: ?Sized> *mut T {
    /// Cast to a pointer to a different type
    #[inline]
    pub const fn cast<U>(self) -> *mut U {
        self as _
    }
}

impl<T: ?Sized> *const T {
    /// Cast to a pointer to a different type
    #[inline]
    pub const fn cast<U>(self) -> *const U {
        self as _
    }
}

Like with NonNull::cast, the input pointed type does not need to be Sized but the output pointed type does, because we wouldn’t know what appropriate pointer metadata (slice length, trait object vtable, …) to insert. The actual requirement is that the pointer is thin, but Sized is the closest approximation we have (until we add something like T: ptr::Pointee<Metadata=()>).

@SimonSapin

This comment has been minimized.

Copy link
Contributor Author

commented Jul 3, 2019

Let’s?

@rfcbot fcp merge

@rfcbot

This comment has been minimized.

Copy link

commented Jul 3, 2019

Team member @SimonSapin has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot

This comment has been minimized.

Copy link

commented Jul 3, 2019

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot

This comment has been minimized.

Copy link

commented Jul 13, 2019

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

The RFC will be merged soon.

SimonSapin added a commit to SimonSapin/rust that referenced this issue Jul 16, 2019

Centril added a commit to Centril/rust that referenced this issue Jul 22, 2019

Rollup merge of rust-lang#62713 - SimonSapin:cast, r=Centril
Stabilize <*mut _>::cast and <*const _>::cast

Fixes rust-lang#60602.

FCP: rust-lang#60602 (comment)

@bors bors closed this in #62713 Jul 22, 2019

mark-i-m added a commit to mark-i-m/rust that referenced this issue Jul 23, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.