mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
change from_slice
to from_str
This commit is contained in:
parent
edd02e01e1
commit
ea3f6210fa
1 changed files with 5 additions and 4 deletions
|
@ -81,7 +81,8 @@ impl IdentStr {
|
||||||
(self as *const IdentStr).cast()
|
(self as *const IdentStr).cast()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_slice(slice: &[u8]) -> Self {
|
fn from_str(str: &str) -> Self {
|
||||||
|
let slice = str.as_bytes();
|
||||||
let len = slice.len();
|
let len = slice.len();
|
||||||
|
|
||||||
match len.cmp(&mem::size_of::<Self>()) {
|
match len.cmp(&mem::size_of::<Self>()) {
|
||||||
|
@ -205,13 +206,13 @@ impl std::ops::Deref for IdentStr {
|
||||||
|
|
||||||
impl From<&str> for IdentStr {
|
impl From<&str> for IdentStr {
|
||||||
fn from(str: &str) -> Self {
|
fn from(str: &str) -> Self {
|
||||||
Self::from_slice(str.as_bytes())
|
Self::from_str(str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<String> for IdentStr {
|
impl From<String> for IdentStr {
|
||||||
fn from(str: String) -> Self {
|
fn from(str: String) -> Self {
|
||||||
Self::from_slice(str.as_bytes())
|
Self::from_str(&str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +268,7 @@ impl std::hash::Hash for IdentStr {
|
||||||
|
|
||||||
impl Clone for IdentStr {
|
impl Clone for IdentStr {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
Self::from_slice(self.as_bytes())
|
Self::from_str(self.as_str())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue