mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-05 17:40:23 +00:00
Introduce PackageName::to_str and From instance
This commit is contained in:
parent
a5ba3581df
commit
203a9aba02
3 changed files with 26 additions and 5 deletions
|
@ -53,7 +53,29 @@ pub enum VersionComparison {
|
|||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
pub struct PackageName<'a>(pub &'a str);
|
||||
pub struct PackageName<'a>(&'a str);
|
||||
|
||||
impl<'a> PackageName<'a> {
|
||||
pub fn to_str(self) -> &'a str {
|
||||
self.0
|
||||
}
|
||||
|
||||
pub fn as_str(&self) -> &'a str {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<PackageName<'a>> for &'a str {
|
||||
fn from(name: PackageName<'a>) -> &'a str {
|
||||
name.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a str> for PackageName<'a> {
|
||||
fn from(string: &'a str) -> Self {
|
||||
Self(string)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
|
||||
pub struct ModuleName<'a>(&'a str);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue