From ad3325db8e6dce3a10b9f8e0319ab9814c7ade1b Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Fri, 26 Mar 2021 11:02:32 +0900 Subject: minor: Remove a few unwraps. --- helix-core/src/syntax.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'helix-core/src/syntax.rs') diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs index a6b1cf61..42bfb855 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -172,7 +172,7 @@ thread_local! { pub struct Syntax { config: Arc, - pub(crate) root_layer: LanguageLayer, + root_layer: LanguageLayer, } fn byte_range_to_str(range: std::ops::Range, source: RopeSlice) -> Cow { @@ -251,7 +251,7 @@ impl Syntax { // // fn parse(language, old_tree, ranges) // - fn tree(&self) -> &Tree { + pub fn tree(&self) -> &Tree { self.root_layer.tree() } // @@ -363,7 +363,7 @@ impl LanguageLayer { // Self { tree: None } // } - fn tree(&self) -> &Tree { + pub fn tree(&self) -> &Tree { // TODO: no unwrap self.tree.as_ref().unwrap() } @@ -1566,7 +1566,7 @@ fn test_parser() { ", ); let syntax = Syntax::new(&source, Arc::new(config)); - let tree = syntax.root_layer.tree.unwrap(); + let tree = syntax.tree(); let root = tree.root_node(); assert_eq!(root.kind(), "source_file"); -- cgit v1.2.3-70-g09d2