pub struct BorrowedAllocator<'a> {
arena: &'a Arena,
interner: Interner<'a>,
}Expand description
Arena-backed builder for borrowed::AozoraNode<'a> and its
payload types.
Owns an Interner keyed off the supplied Arena; both string
content and per-variant payloads land in the arena, so dropping the
arena tears the entire AST down in one step (no per-node Drop
runs, no Box::drop traffic).
Fields§
§arena: &'a Arena§interner: Interner<'a>Implementations§
Source§impl<'a> BorrowedAllocator<'a>
impl<'a> BorrowedAllocator<'a>
Sourcepub fn with_capacity(arena: &'a Arena, interner_capacity: usize) -> Self
pub fn with_capacity(arena: &'a Arena, interner_capacity: usize) -> Self
New allocator with a fresh interner sized to interner_capacity.
Capacity is rounded up to the next power of two by the interner.
Sourcepub fn new(arena: &'a Arena) -> Self
pub fn new(arena: &'a Arena) -> Self
Construct with the interner’s default initial capacity (64 → 64 after power-of-two rounding).
Sourcepub fn arena(&self) -> &'a Arena
pub fn arena(&self) -> &'a Arena
Borrow the underlying arena. Useful for callers that need to emit an arena-allocated normalised text alongside the AST.
Sourcepub fn into_interner(self) -> Interner<'a>
pub fn into_interner(self) -> Interner<'a>
Finish allocation and return the interner so the caller can
inspect its dedup counters (cache hits, table hits, allocs,
average probe length). The interner’s &'a arena reference
continues to keep the interned strings alive.
Sourcepub fn content_plain(&mut self, s: &str) -> Content<'a>
pub fn content_plain(&mut self, s: &str) -> Content<'a>
Build a plain-text body content. Empty input canonicalises to
Segments(&[]) (the legacy owned shape did the same).
Sourcepub fn content_segments(&mut self, segs: &[Segment<'a>]) -> Content<'a>
pub fn content_segments(&mut self, segs: &[Segment<'a>]) -> Content<'a>
Build a body content from a sequence of segments. Empty input →
Segments(&[]); all-Text input collapses into a single
concatenated Plain (interned).
Sourcepub fn seg_gaiji(&self, g: &'a Gaiji<'a>) -> Segment<'a>
pub fn seg_gaiji(&self, g: &'a Gaiji<'a>) -> Segment<'a>
Segment::Gaiji(g) — wraps a payload built via Self::make_gaiji.
Sourcepub fn seg_annotation(&self, a: &'a Annotation<'a>) -> Segment<'a>
pub fn seg_annotation(&self, a: &'a Annotation<'a>) -> Segment<'a>
Segment::Annotation(a) — wraps a payload built via Self::make_annotation.
Sourcepub fn make_gaiji(
&mut self,
description: &str,
ucs: Option<Resolved>,
mencode: Option<&str>,
) -> &'a Gaiji<'a>
pub fn make_gaiji( &mut self, description: &str, ucs: Option<Resolved>, mencode: Option<&str>, ) -> &'a Gaiji<'a>
Build a Gaiji payload. Use Self::seg_gaiji to wrap as a
segment, or Self::gaiji to wrap as a node.
Sourcepub fn make_annotation(
&mut self,
raw: &str,
kind: AnnotationKind,
) -> &'a Annotation<'a>
pub fn make_annotation( &mut self, raw: &str, kind: AnnotationKind, ) -> &'a Annotation<'a>
Build an Annotation payload. Use Self::seg_annotation to
wrap as a segment, or Self::annotation to wrap as a node.
raw carries the borrowed::NonEmptyStr invariant.
§Panics
Panics if raw is empty. Phase 3 emits annotation only after
at least one byte landed in the bracket body.
Sourcepub fn ruby(
&self,
base: Content<'a>,
reading: Content<'a>,
delim_explicit: bool,
) -> AozoraNode<'a>
pub fn ruby( &self, base: Content<'a>, reading: Content<'a>, delim_explicit: bool, ) -> AozoraNode<'a>
AozoraNode::Ruby(Ruby { base, reading, delim_explicit }).
base and reading carry the borrowed::NonEmpty
invariant. Phase 3 only emits Ruby once both are non-empty,
so this expect is a contract-check; an empty payload here
signals a classifier bug.
§Panics
Panics if base or reading is empty. Phase 3 emit-sites
classify only after the body is populated, so the panic
represents a pipeline-internal bug — the
borrowed::NonEmpty payload encodes this invariant at the
type level.
Sourcepub fn bouten(
&self,
kind: BoutenKind,
target: Content<'a>,
position: BoutenPosition,
) -> AozoraNode<'a>
pub fn bouten( &self, kind: BoutenKind, target: Content<'a>, position: BoutenPosition, ) -> AozoraNode<'a>
AozoraNode::Bouten(Bouten { kind, target, position }).
target carries the borrowed::NonEmpty invariant —
Phase 3 resolves the forward reference before emitting.
§Panics
Panics if target is empty. The forward-reference resolver
in Phase 3 always lands a non-empty target before emit; an
empty payload here signals a classifier bug.
Sourcepub fn tate_chu_yoko(&self, text: Content<'a>) -> AozoraNode<'a>
pub fn tate_chu_yoko(&self, text: Content<'a>) -> AozoraNode<'a>
AozoraNode::TateChuYoko(TateChuYoko { text }).
text carries the borrowed::NonEmpty invariant.
§Panics
Panics if text is empty.
Sourcepub fn gaiji(&self, g: &'a Gaiji<'a>) -> AozoraNode<'a>
pub fn gaiji(&self, g: &'a Gaiji<'a>) -> AozoraNode<'a>
AozoraNode::Gaiji(g).
Sourcepub fn indent(&self, i: Indent) -> AozoraNode<'a>
pub fn indent(&self, i: Indent) -> AozoraNode<'a>
AozoraNode::Indent(i).
Sourcepub fn align_end(&self, a: AlignEnd) -> AozoraNode<'a>
pub fn align_end(&self, a: AlignEnd) -> AozoraNode<'a>
AozoraNode::AlignEnd(a).
Sourcepub fn warichu(&self, upper: Content<'a>, lower: Content<'a>) -> AozoraNode<'a>
pub fn warichu(&self, upper: Content<'a>, lower: Content<'a>) -> AozoraNode<'a>
AozoraNode::Warichu(Warichu { upper, lower }).
Sourcepub fn keigakomi(&self, k: Keigakomi) -> AozoraNode<'a>
pub fn keigakomi(&self, k: Keigakomi) -> AozoraNode<'a>
AozoraNode::Keigakomi(k).
Sourcepub fn page_break(&self) -> AozoraNode<'a>
pub fn page_break(&self) -> AozoraNode<'a>
AozoraNode::PageBreak.
Sourcepub fn section_break(&self, k: SectionKind) -> AozoraNode<'a>
pub fn section_break(&self, k: SectionKind) -> AozoraNode<'a>
AozoraNode::SectionBreak(k).
Sourcepub fn aozora_heading(
&self,
kind: AozoraHeadingKind,
text: Content<'a>,
) -> AozoraNode<'a>
pub fn aozora_heading( &self, kind: AozoraHeadingKind, text: Content<'a>, ) -> AozoraNode<'a>
AozoraNode::AozoraHeading(AozoraHeading { kind, text }).
text carries the borrowed::NonEmpty invariant.
§Panics
Panics if text is empty.
Sourcepub fn heading_hint(&mut self, level: u8, target: &str) -> AozoraNode<'a>
pub fn heading_hint(&mut self, level: u8, target: &str) -> AozoraNode<'a>
AozoraNode::HeadingHint(HeadingHint { level, target }).
target carries the borrowed::NonEmptyStr invariant.
§Panics
Panics if target is empty. Phase 3 emits the hint only
after the forward-reference target lands non-empty; an empty
payload here signals a classifier bug.
Sourcepub fn sashie(
&mut self,
file: &str,
caption: Option<Content<'a>>,
) -> AozoraNode<'a>
pub fn sashie( &mut self, file: &str, caption: Option<Content<'a>>, ) -> AozoraNode<'a>
AozoraNode::Sashie(Sashie { file, caption }).
file carries the borrowed::NonEmptyStr invariant.
§Panics
Panics if file is empty.
Sourcepub fn kaeriten(&mut self, mark: &str) -> AozoraNode<'a>
pub fn kaeriten(&mut self, mark: &str) -> AozoraNode<'a>
AozoraNode::Kaeriten(Kaeriten { mark }).
mark carries the borrowed::NonEmptyStr invariant.
§Panics
Panics if mark is empty.
Sourcepub fn annotation(&self, a: &'a Annotation<'a>) -> AozoraNode<'a>
pub fn annotation(&self, a: &'a Annotation<'a>) -> AozoraNode<'a>
AozoraNode::Annotation(a).
Sourcepub fn double_ruby(&self, content: Content<'a>) -> AozoraNode<'a>
pub fn double_ruby(&self, content: Content<'a>) -> AozoraNode<'a>
AozoraNode::DoubleRuby(DoubleRuby { content }).
content carries the borrowed::NonEmpty invariant — Phase 3
pre-filters 《《》》 with empty body into plain text so this
path is never reached with an empty payload.
§Panics
Panics if content is empty. Phase 3’s pre-filter is the
gate; an empty payload here signals a classifier bug.
Sourcepub fn container(&self, c: Container) -> AozoraNode<'a>
pub fn container(&self, c: Container) -> AozoraNode<'a>
AozoraNode::Container(c).
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for BorrowedAllocator<'a>
impl<'a> !RefUnwindSafe for BorrowedAllocator<'a>
impl<'a> !Send for BorrowedAllocator<'a>
impl<'a> !Sync for BorrowedAllocator<'a>
impl<'a> Unpin for BorrowedAllocator<'a>
impl<'a> UnsafeUnpin for BorrowedAllocator<'a>
impl<'a> !UnwindSafe for BorrowedAllocator<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more