More consistent Packed<T> to Content conversion methods (#6579)

This commit is contained in:
Laurenz 2025-07-09 15:40:22 +02:00 committed by GitHub
parent f9b01f595d
commit a45c3388a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 5 deletions

View File

@ -64,6 +64,16 @@ impl<T: NativeElement> Packed<T> {
self.0
}
/// Pack back into a reference to content.
pub fn pack_ref(&self) -> &Content {
&self.0
}
/// Pack back into a mutable reference to content.
pub fn pack_mut(&mut self) -> &mut Content {
&mut self.0
}
/// Extract the raw underlying element.
pub fn unpack(self) -> T {
// This function doesn't yet need owned self, but might in the future.
@ -94,10 +104,6 @@ impl<T: NativeElement> Packed<T> {
pub fn set_location(&mut self, location: Location) {
self.0.set_location(location);
}
pub fn as_content(&self) -> &Content {
&self.0
}
}
impl<T: NativeElement> AsRef<T> for Packed<T> {

View File

@ -141,7 +141,7 @@ impl RawContent {
/// Clones a packed element into new raw content.
pub(super) fn clone_impl<E: NativeElement>(elem: &Packed<E>) -> Self {
let raw = &elem.as_content().0;
let raw = &elem.pack_ref().0;
let header = raw.header();
RawContent::create(
elem.as_ref().clone(),