pub struct LinkTable<K> { /* private fields */ }Expand description
Table for tracking links between ports.
Two ports are connected when they share the same link. Links are named and scoped via closed regions. Links from one closed region are not visible in another. Open regions are considered to form the same scope as their parent region. Links do not have a unique point of declaration.
The link table keeps track of an association between a key of type K and
the link indices within each closed region. When resolving links from a text format,
K is the name of the link as a string slice. However the link table might
is also useful in other contexts where the key is not a string when constructing
a module from a different representation.
§Examples
let mut links = LinkTable::new();
links.enter(RegionId(0));
let foo_0 = links.use_link("foo");
let bar_0 = links.use_link("bar");
assert_eq!(foo_0, links.use_link("foo"));
assert_eq!(bar_0, links.use_link("bar"));
let (num_links, num_ports) = links.exit();
assert_eq!(num_links, 2);
assert_eq!(num_ports, 4);Implementations§
Source§impl<K> LinkTable<K>
impl<K> LinkTable<K>
Sourcepub fn exit(&mut self) -> (u32, u32)
pub fn exit(&mut self) -> (u32, u32)
Exit a previously entered scope, returning the number of links and ports in the scope.