pub struct Text { /* private fields */ }Available on crate feature
document only.Expand description
Text made of Spans, each carrying a Role.
A &str or String converts into plain text, so most methods that take
impl Into<Text> accept either.
use ctl_core::document::{Role, Text};
let text = Text::new().token("--force").then(" overwrites ").id("A-1");
assert_eq!(text.spans().len(), 3);
assert_eq!(text.spans()[0].role(), Role::Token);Implementations§
Source§impl Text
impl Text
Sourcepub fn plain(value: impl Into<String>) -> Self
pub fn plain(value: impl Into<String>) -> Self
Start text with one Role::Plain span holding value.
Sourcepub fn span(self, role: Role, value: impl Into<String>) -> Self
pub fn span(self, role: Role, value: impl Into<String>) -> Self
Append a span holding value in role.
Sourcepub fn then(self, value: impl Into<String>) -> Self
pub fn then(self, value: impl Into<String>) -> Self
Append value in Role::Plain. A chain of then and role methods
reads left to right.
Sourcepub fn token(self, value: impl Into<String>) -> Self
pub fn token(self, value: impl Into<String>) -> Self
Append value in Role::Token: a flag, command, or field name.
Sourcepub fn id(self, value: impl Into<String>) -> Self
pub fn id(self, value: impl Into<String>) -> Self
Append value in Role::Id: the id of a row, patch, or package.
Sourcepub fn value(self, value: impl Into<String>) -> Self
pub fn value(self, value: impl Into<String>) -> Self
Append value in Role::Value: a value or a metavar.
Sourcepub fn muted(self, value: impl Into<String>) -> Self
pub fn muted(self, value: impl Into<String>) -> Self
Append value in Role::Muted: secondary information.
Sourcepub fn success(self, value: impl Into<String>) -> Self
pub fn success(self, value: impl Into<String>) -> Self
Append value in Role::Success.
Sourcepub fn warning(self, value: impl Into<String>) -> Self
pub fn warning(self, value: impl Into<String>) -> Self
Append value in Role::Warning.
Sourcepub fn error(self, value: impl Into<String>) -> Self
pub fn error(self, value: impl Into<String>) -> Self
Append value in Role::Error.
Trait Implementations§
impl Eq for Text
impl StructuralPartialEq for Text
Auto Trait Implementations§
impl Forget for Text
impl Freeze for Text
impl Move for Text
impl RefUnwindSafe for Text
impl Send for Text
impl Sync for Text
impl Unpin for Text
impl UnsafeUnpin for Text
impl UnwindSafe for Text
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
Mutably borrows from an owned value. Read more