pub enum Segment<'a> {
Plain {
text: &'a str,
},
Rubied {
text: &'a str,
ruby: &'a str,
},
}
Expand description
A part of a RubyString
that either has no ruby glosses or exactly
one ruby gloss attached to it. This type appears:
- when iterating over the segments of a
RubyStrings
using itssegments
method, or - when
extend()
ing aRubyString
using animpl Iterator<Item = Segment>
, - when building a
RubyString
throughcollect()
on animpl Iterator<Item = Segment>
.
Variants§
Plain
A piece of text that does not have any ruby glosses attached to it.
Rubied
A piece of text that has exactly one ruby gloss attached to its entirety.
Implementations§
Source§impl<'a> Segment<'a>
impl<'a> Segment<'a>
Sourcepub fn plain_text(&self) -> &'a str
pub fn plain_text(&self) -> &'a str
Returns only the plain text in this segment, ignoring any ruby glosses attached to it.
Sourcepub fn to_interlinear_encoding(&self) -> String
pub fn to_interlinear_encoding(&self) -> String
Returns an encoding of this segment as a plain String using interlinear annotation characters.
let s = Segment::Plain { text: "です" };
assert_eq!(s.to_interlinear_encoding(), "です");
let s = Segment::Rubied { text: "東京", ruby: "とうきょう" };
assert_eq!(s.to_interlinear_encoding(), "\u{FFF9}東京\u{FFFA}とうきょう\u{FFFB}");
Trait Implementations§
Source§impl<'a> Extend<Segment<'a>> for RubyString
impl<'a> Extend<Segment<'a>> for RubyString
Source§fn extend<I: IntoIterator<Item = Segment<'a>>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = Segment<'a>>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl<'a> FromIterator<Segment<'a>> for RubyString
impl<'a> FromIterator<Segment<'a>> for RubyString
Source§fn from_iter<I: IntoIterator<Item = Segment<'a>>>(iter: I) -> RubyString
fn from_iter<I: IntoIterator<Item = Segment<'a>>>(iter: I) -> RubyString
Creates a value from an iterator. Read more
impl<'a> Copy for Segment<'a>
impl<'a> Eq for Segment<'a>
impl<'a> StructuralPartialEq for Segment<'a>
Auto Trait Implementations§
impl<'a> Freeze for Segment<'a>
impl<'a> RefUnwindSafe for Segment<'a>
impl<'a> Send for Segment<'a>
impl<'a> Sync for Segment<'a>
impl<'a> Unpin for Segment<'a>
impl<'a> UnwindSafe for Segment<'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
Mutably borrows from an owned value. Read more