[−][src]Struct unsegen::base::grapheme_cluster::GraphemeCluster
A single grapheme cluster encoded in utf8. It may consist of multiple bytes or even multiple chars. For details on what a grapheme cluster is, read this or similar.
Implementations
impl GraphemeCluster
[src]
pub fn as_str<'a>(&'a self) -> &'a str
[src]
Get the underlying grapheme cluster as a String slice.
Examples:
use unsegen::base::GraphemeCluster; assert_eq!(GraphemeCluster::try_from('a').unwrap().as_str(), "a");
pub fn space() -> Self
[src]
Safely create a single space character (i.e., 0x20) grapheme cluster.
Examples:
use unsegen::base::GraphemeCluster; assert_eq!(GraphemeCluster::space().as_str(), " ");
pub fn clear(&mut self)
[src]
Replace the current cluster with a single space character (i.e., 0x20)
Examples:
use unsegen::base::GraphemeCluster; let mut cluster = GraphemeCluster::try_from('a').unwrap(); cluster.clear(); assert_eq!(cluster.as_str(), " ");
pub fn try_from(c: char) -> Result<Self, GraphemeClusterError>
[src]
Try to create a grapheme cluster from a character. If c is not a single grapheme cluster, a GraphemeClusterError is returned.
Examples:
use unsegen::base::GraphemeCluster; assert_eq!(GraphemeCluster::try_from('a').unwrap().as_str(), "a");
pub fn all_from_str<'a>(string: &'a str) -> GraphemeClusterIter<'a>ⓘNotable traits for GraphemeClusterIter<'a>
impl<'a> Iterator for GraphemeClusterIter<'a> type Item = GraphemeCluster;
[src]
Notable traits for GraphemeClusterIter<'a>
impl<'a> Iterator for GraphemeClusterIter<'a> type Item = GraphemeCluster;
Retrieve all grapheme clusters from the given string.
Examples:
use unsegen::base::GraphemeCluster; let mut clusters = GraphemeCluster::all_from_str("ab d"); assert_eq!(clusters.next(), Some(GraphemeCluster::try_from('a').unwrap())); assert_eq!(clusters.next(), Some(GraphemeCluster::try_from('b').unwrap())); assert_eq!(clusters.next(), Some(GraphemeCluster::try_from(' ').unwrap())); assert_eq!(clusters.next(), Some(GraphemeCluster::try_from('d').unwrap())); assert_eq!(clusters.next(), None);
pub fn width(&self) -> usize
[src]
Calculate the unicode width of the given grapheme cluster.
Examples:
use unsegen::base::GraphemeCluster; assert_eq!(GraphemeCluster::try_from('a').unwrap().width(), 1);
Trait Implementations
impl Clone for GraphemeCluster
[src]
fn clone(&self) -> GraphemeCluster
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for GraphemeCluster
[src]
impl FromStr for GraphemeCluster
[src]
type Err = GraphemeClusterError
The associated error which can be returned from parsing.
fn from_str(text: &str) -> Result<Self, Self::Err>
[src]
impl PartialEq<GraphemeCluster> for GraphemeCluster
[src]
fn eq(&self, other: &GraphemeCluster) -> bool
[src]
fn ne(&self, other: &GraphemeCluster) -> bool
[src]
impl StructuralPartialEq for GraphemeCluster
[src]
Auto Trait Implementations
impl RefUnwindSafe for GraphemeCluster
impl Send for GraphemeCluster
impl Sync for GraphemeCluster
impl Unpin for GraphemeCluster
impl UnwindSafe for GraphemeCluster
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,