MCPcopy Create free account
hub / github.com/MegEngine/MegFlow / parse

Function parse

flow-rs/src/loader/python/port.rs:82–102  ·  view source on GitHub ↗
(s: &str)

Source from the content-addressed store, hash-verified

80}
81
82pub(super) fn parse<T>(s: &str) -> (String, AnyPort<std::sync::Arc<T>>) {
83 let mut ss = s.split(':');
84 let name = ss.next().unwrap();
85 ss.next()
86 .map(|x| {
87 if x == "[]" {
88 (
89 format!("[{}]", name),
90 AnyPort::new(name.to_owned(), PortTy::List),
91 )
92 } else if x == "{}" {
93 (
94 format!("{{{}}}", name),
95 AnyPort::new(name.to_owned(), PortTy::Dict),
96 )
97 } else {
98 unreachable!("unexpected port type {}", x)
99 }
100 })
101 .unwrap_or_else(|| (name.to_owned(), AnyPort::new(name.to_owned(), PortTy::Unit)))
102}
103
104pub(super) fn port_name(s: &str) -> String {
105 let mut ss = s.split(':');

Callers 4

newMethod · 0.70
translate_connFunction · 0.50
dyn_inp_transFunction · 0.50
dyn_out_transFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected