1
Fork 0

avoid an unnecessary call to Pointer::into_parts, and caution against into_pointer_or_addr

This commit is contained in:
Ralf Jung 2022-04-18 11:48:09 -04:00
parent 3236092503
commit c83241a7f9
2 changed files with 6 additions and 3 deletions

View file

@ -201,6 +201,10 @@ impl<Tag> From<Pointer<Tag>> for Pointer<Option<Tag>> {
}
impl<Tag> Pointer<Option<Tag>> {
/// Convert this pointer that *might* have a tag into a pointer that *definitely* has a tag, or
/// an absolute address.
///
/// This is rarely what you want; call `ptr_try_get_alloc_id` instead.
pub fn into_pointer_or_addr(self) -> Result<Pointer<Tag>, Size> {
match self.provenance {
Some(tag) => Ok(Pointer::new(tag, self.offset)),