ReprTree: add from_char()
This commit is contained in:
parent
17b58e6bca
commit
1575fa756e
1 changed files with 9 additions and 1 deletions
|
@ -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<RwLock<Context>>, c: char) -> Arc<RwLock<Self>> {
|
||||
let buf = r3vi::buffer::singleton::SingletonBuffer::<char>::new(c);
|
||||
ReprTree::new_leaf(
|
||||
(ctx, "( Char )"),
|
||||
buf.get_port().into()
|
||||
)
|
||||
}
|
||||
|
||||
pub fn new_leaf(type_tag: impl Into<TypeTerm>, port: AnyOuterViewPort) -> Arc<RwLock<Self>> {
|
||||
let mut tree = ReprTree::new(type_tag.into());
|
||||
tree.insert_leaf(vec![].into_iter(), port);
|
||||
|
|
Loading…
Reference in a new issue