From 1575fa756ea6b37ff4535e621afbb63d2c37132b Mon Sep 17 00:00:00 2001 From: Michael Sippel Date: Sat, 25 Mar 2023 08:49:19 +0100 Subject: [PATCH] ReprTree: add from_char() --- nested/src/type_system/repr_tree.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/nested/src/type_system/repr_tree.rs b/nested/src/type_system/repr_tree.rs index 7fa3a1c..42eac89 100644 --- a/nested/src/type_system/repr_tree.rs +++ b/nested/src/type_system/repr_tree.rs @@ -1,7 +1,7 @@ use { r3vi::view::{AnyOuterViewPort, OuterViewPort, View}, crate::{ - type_system::{TypeTerm} + type_system::{TypeTerm, Context} }, std::{ collections::HashMap, @@ -31,6 +31,14 @@ impl ReprTree { &self.type_tag } + pub fn from_char(ctx: &Arc>, c: char) -> Arc> { + let buf = r3vi::buffer::singleton::SingletonBuffer::::new(c); + ReprTree::new_leaf( + (ctx, "( Char )"), + buf.get_port().into() + ) + } + pub fn new_leaf(type_tag: impl Into, port: AnyOuterViewPort) -> Arc> { let mut tree = ReprTree::new(type_tag.into()); tree.insert_leaf(vec![].into_iter(), port);