mirror of
https://github.com/typst/typst
synced 2025-07-11 22:52:53 +08:00
More consistent Packed<T>
to Content
conversion methods (#6579)
This commit is contained in:
parent
f9b01f595d
commit
a45c3388a6
@ -64,6 +64,16 @@ impl<T: NativeElement> Packed<T> {
|
|||||||
self.0
|
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.
|
/// Extract the raw underlying element.
|
||||||
pub fn unpack(self) -> T {
|
pub fn unpack(self) -> T {
|
||||||
// This function doesn't yet need owned self, but might in the future.
|
// 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) {
|
pub fn set_location(&mut self, location: Location) {
|
||||||
self.0.set_location(location);
|
self.0.set_location(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_content(&self) -> &Content {
|
|
||||||
&self.0
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: NativeElement> AsRef<T> for Packed<T> {
|
impl<T: NativeElement> AsRef<T> for Packed<T> {
|
||||||
|
@ -141,7 +141,7 @@ impl RawContent {
|
|||||||
|
|
||||||
/// Clones a packed element into new raw content.
|
/// Clones a packed element into new raw content.
|
||||||
pub(super) fn clone_impl<E: NativeElement>(elem: &Packed<E>) -> Self {
|
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();
|
let header = raw.header();
|
||||||
RawContent::create(
|
RawContent::create(
|
||||||
elem.as_ref().clone(),
|
elem.as_ref().clone(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user