pub struct ListItem { /* private fields */ }Expand description
列表中的单个条目,支持递归嵌套子列表。
§Examples
use easypdf_core::ListItem;
let item = ListItem::new("Top level");
assert_eq!(item.text(), "Top level");
assert_eq!(item.level(), 0);
assert!(item.children().is_empty());Implementations§
Source§impl ListItem
impl ListItem
Sourcepub fn new(text: impl Into<String>) -> Self
pub fn new(text: impl Into<String>) -> Self
创建指定层级的列表条目。
§Examples
use easypdf_core::ListItem;
let item = ListItem::new("Hello");
assert_eq!(item.text(), "Hello");Sourcepub const fn with_level(self, level: u8) -> Self
pub const fn with_level(self, level: u8) -> Self
设置嵌套层级。
§Examples
use easypdf_core::ListItem;
let item = ListItem::new("Nested").with_level(2);
assert_eq!(item.level(), 2);Sourcepub fn with_child(self, child: ListItem) -> Self
pub fn with_child(self, child: ListItem) -> Self
追加子条目。
§Examples
use easypdf_core::ListItem;
let item = ListItem::new("Parent").with_child(ListItem::new("Child"));
assert_eq!(item.children().len(), 1);Sourcepub fn children_mut(&mut self) -> &mut Vec<ListItem>
pub fn children_mut(&mut self) -> &mut Vec<ListItem>
返回可变子条目列表引用。
Trait Implementations§
impl StructuralPartialEq for ListItem
Auto Trait Implementations§
impl Freeze for ListItem
impl RefUnwindSafe for ListItem
impl Send for ListItem
impl Sync for ListItem
impl Unpin for ListItem
impl UnsafeUnpin for ListItem
impl UnwindSafe for ListItem
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more