Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
QuarticCat committed Sep 30, 2022
1 parent 7d36c5f commit 2293886
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/diff/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub struct SyntaxRefOrId<'a> {
phantom: PhantomData<&'a Syntax<'a>>,
}

impl SyntaxRefOrId<'_> {
impl<'a> SyntaxRefOrId<'a> {
pub fn is_ref(&self) -> bool {
self.data & 1 == 0
}
Expand All @@ -44,7 +44,7 @@ impl SyntaxRefOrId<'_> {
self.data & 1 == 1
}

pub fn get_ref<'a>(&self) -> Option<&'a Syntax<'a>> {
pub fn get_ref(&self) -> Option<&'a Syntax<'a>> {
if self.is_ref() {
Some(unsafe { transmute_copy(&self.data) })
} else {
Expand All @@ -56,7 +56,7 @@ impl SyntaxRefOrId<'_> {
impl<'a> From<&'a Syntax<'a>> for SyntaxRefOrId<'a> {
fn from(s: &'a Syntax<'a>) -> Self {
Self {
data: unsafe { transmute_copy(&s) },
data: s as *const _ as _,
phantom: PhantomData,
}
}
Expand All @@ -77,10 +77,8 @@ fn next_sibling_syntax<'a>(syntax: &'a Syntax<'a>) -> SyntaxRefOrId<'a> {
}

fn next_child_syntax<'a>(syntax: &'a Syntax<'a>, children: &[&'a Syntax<'a>]) -> SyntaxRefOrId<'a> {
children
.get(0)
.copied()
.map_or(Some(syntax.id()).into(), |s| s.into())
let child = children.get(0).copied();
child.map_or(Some(syntax.id()).into(), |s| s.into())
}

/// A vertex in a directed acyclic graph that represents a diff.
Expand Down

0 comments on commit 2293886

Please sign in to comment.