[][src]Enum ruby_string::Segment

pub enum Segment<'a> {
    Plain {
        text: &'a str,
    },
    Rubied {
        text: &'a str,
        ruby: &'a str,
    },
}

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 its segments method, or
  • when extend()ing a RubyString using an impl Iterator<Item = Segment>,
  • when building a RubyString through collect() on an impl Iterator<Item = Segment>.

Variants

Plain

A piece of text that does not have any ruby glosses attached to it.

Fields of Plain

text: &'a str
Rubied

A piece of text that has exactly one ruby gloss attached to its entirety.

Fields of Rubied

text: &'a strruby: &'a str

Implementations

impl<'a> Segment<'a>[src]

pub fn plain_text(&self) -> &'a str[src]

Returns only the plain text in this segment, ignoring any ruby glosses attached to it.

pub fn to_interlinear_encoding(&self) -> String[src]

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

impl<'a> Clone for Segment<'a>[src]

impl<'a> Copy for Segment<'a>[src]

impl<'a> Debug for Segment<'a>[src]

impl<'a> Eq for Segment<'a>[src]

impl<'a> Extend<Segment<'a>> for RubyString[src]

impl<'a> FromIterator<Segment<'a>> for RubyString[src]

impl<'a> PartialEq<Segment<'a>> for Segment<'a>[src]

impl<'a> StructuralEq for Segment<'a>[src]

impl<'a> StructuralPartialEq for Segment<'a>[src]

Auto Trait Implementations

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.