generated from IWANABETHATGUY/tower-lsp-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref: more interning, fix model fields parsing
- Loading branch information
Showing
11 changed files
with
199 additions
and
140 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use std::{hash::Hash, marker::PhantomData, ops::Deref}; | ||
|
||
use lasso::Spur; | ||
|
||
/// Type-safe wrapper around [Spur]. | ||
#[derive(Debug)] | ||
pub struct Symbol<T> { | ||
inner: Spur, | ||
_kind: PhantomData<T>, | ||
} | ||
|
||
// TODO: Remove in favor of strict-type symbols | ||
impl<T> From<Spur> for Symbol<T> { | ||
#[inline] | ||
fn from(inner: Spur) -> Self { | ||
Symbol { | ||
inner, | ||
_kind: PhantomData, | ||
} | ||
} | ||
} | ||
|
||
impl<T> Clone for Symbol<T> { | ||
#[inline] | ||
fn clone(&self) -> Self { | ||
Symbol { | ||
inner: self.inner, | ||
_kind: PhantomData, | ||
} | ||
} | ||
} | ||
|
||
impl<T> Copy for Symbol<T> {} | ||
impl<T> Eq for Symbol<T> {} | ||
impl<T> PartialEq for Symbol<T> { | ||
#[inline] | ||
fn eq(&self, other: &Self) -> bool { | ||
self.inner.eq(&other.inner) | ||
} | ||
} | ||
|
||
impl<T> Hash for Symbol<T> { | ||
#[inline] | ||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) { | ||
self.inner.hash(state) | ||
} | ||
} | ||
|
||
impl<T> Deref for Symbol<T> { | ||
type Target = Spur; | ||
fn deref(&self) -> &Self::Target { | ||
&self.inner | ||
} | ||
} |
Oops, something went wrong.