You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
551 B
46 lines
551 B
//! Word splitting
|
|
use super::*;
|
|
use std::{
|
|
borrow::Borrow,
|
|
};
|
|
|
|
#[derive(Debug, PartialEq, Eq)]
|
|
#[repr(transparent)]
|
|
pub struct Word(str);
|
|
|
|
impl Word
|
|
{
|
|
pub fn new<'a>(from: &'a str) -> &'a Self
|
|
{
|
|
unsafe {
|
|
std::mem::transmute(from)
|
|
}
|
|
}
|
|
}
|
|
|
|
impl<'a> From<&'a str> for &'a Word
|
|
{
|
|
fn from(from: &'a str) -> Self
|
|
{
|
|
Word::new(from)
|
|
}
|
|
}
|
|
|
|
impl AsRef<str> for Word
|
|
{
|
|
fn as_ref(&self) -> &str
|
|
{
|
|
&self.0
|
|
}
|
|
}
|
|
|
|
impl AsRef<Word> for str
|
|
{
|
|
fn as_ref(&self) -> &Word
|
|
{
|
|
Word::new(self)
|
|
}
|
|
}
|
|
|
|
//impl Borrow<>
|