Skip to content

Magicloud/just-string

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Just String

crates docs

This is a container to hold various kinds of strings in Rust, for user who does not care about the (performance) differences in his case.

And this container tries to be transparent, which means in most cases, user does not have to extract the string out to use them. But mutating them must be done by getting the inner string out. The implementation does not support creating a new string in place, or mutating to original strings.

The only thing user needs to care is defined as:

enum JustString<'a> {
    RefStr(&'a str),
    CowStr(Cow<'a, str>),
    BoxStr(Box<str>),
    RefString(&'a String),
    String(String),
}

There are five kinds of strings could be held by this container. I did not impl Into<JustString<'_>> sololy because knowing what is putting into the container every time using it might be helpful.

A lot of other trais are implemented. Mostly copied from what String does. And Serialize, just to omit the tags. The core trais are AsRef and Deref.

About

Container for various kinds of strings

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages