From 20b1a38414101f842a6d9201133a5aaaa45a7cec Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 31 Jan 2022 16:06:44 +0100 Subject: Switch from `Rc` to `Arc` --- src/syntax/mod.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/syntax') diff --git a/src/syntax/mod.rs b/src/syntax/mod.rs index 03a496dd..a26384e1 100644 --- a/src/syntax/mod.rs +++ b/src/syntax/mod.rs @@ -7,7 +7,7 @@ mod span; use std::fmt::{self, Debug, Display, Formatter}; use std::ops::Range; -use std::rc::Rc; +use std::sync::Arc; pub use highlight::*; pub use pretty::*; @@ -24,7 +24,7 @@ use crate::util::EcoString; #[derive(Clone, PartialEq)] pub enum Green { /// A reference-counted inner node. - Node(Rc), + Node(Arc), /// A terminal, owned token. Token(GreenData), } @@ -76,7 +76,7 @@ impl Green { pub fn convert(&mut self, kind: NodeKind) { match self { Self::Node(node) => { - let node = Rc::make_mut(node); + let node = Arc::make_mut(node); node.erroneous |= kind.is_error(); node.data.kind = kind; } @@ -187,12 +187,12 @@ impl GreenNode { impl From for Green { fn from(node: GreenNode) -> Self { - Rc::new(node).into() + Arc::new(node).into() } } -impl From> for Green { - fn from(node: Rc) -> Self { +impl From> for Green { + fn from(node: Arc) -> Self { Self::Node(node) } } @@ -259,7 +259,7 @@ pub struct RedNode { impl RedNode { /// Create a new red node from a root [`GreenNode`]. - pub fn from_root(root: Rc, id: SourceId) -> Self { + pub fn from_root(root: Arc, id: SourceId) -> Self { Self { id, offset: 0, green: root.into() } } @@ -611,9 +611,9 @@ pub enum NodeKind { Emph, /// An arbitrary number of backticks followed by inner contents, terminated /// with the same number of backticks: `` `...` ``. - Raw(Rc), + Raw(Arc), /// Dollar signs surrounding inner contents. - Math(Rc), + Math(Arc), /// A section heading: `= Introduction`. Heading, /// An item in an unordered list: `- ...`. -- cgit v1.2.3