use crate::{CharIter, String};
#[doc = crate::_tags!(text)]
#[doc = crate::_doc_location!("text/grapheme")]
#[cfg_attr(nightly_doc, doc(cfg(feature = "alloc")))]
#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[repr(transparent)]
pub struct GraphemeString(String);
#[rustfmt::skip]
impl GraphemeString {
#[must_use]
pub const fn new() -> GraphemeString { Self(String::new()) }
#[must_use]
#[inline(always)]
pub const fn len(&self) -> usize { self.0.len() }
#[must_use]
#[inline(always)]
pub const fn is_empty(&self) -> bool { self.0.len() == 0 }
#[inline(always)]
pub fn clear(&mut self) { self.0.clear(); }
pub const fn chars(&self) -> CharIter<'_, &str> { CharIter::<&str>::new(self.0.as_str()) }
}
#[rustfmt::skip]
mod core_impls {
use super::*;
use crate::{ConstInit, Formatter, FmtResult, Debug, Display};
impl Default for GraphemeString {
fn default() -> Self { Self::new() }
}
impl ConstInit for GraphemeString {
const INIT: Self = Self::new();
}
impl Display for GraphemeString {
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult<()> { write!(f, "{}", self.0) }
}
impl Debug for GraphemeString {
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult<()> { write!(f, "{:?}", self.0) }
}
impl From<char> for GraphemeString {
fn from(s: char) -> GraphemeString {
GraphemeString(s.into())
}
}
}