Xazax-hun / domains-oxide

Toy language to help experiment with numerical domains for abstract interpretation
Apache License 2.0
2 stars 0 forks source link

IntoIterator for CFG #2

Open Xazax-hun opened 1 year ago

Xazax-hun commented 1 year ago

Instead of a blocks/elements etc method, consider IntoIterator? Can we have random access ones?

Xazax-hun commented 7 months ago

It could look something like, and similar for other types:

impl<'a, T: CfgBlock> IntoIterator for &'a T {
    type Item = <T as CfgBlock>::Operation;
    type IntoIter = std::slice::Iter<'a, Self::Item>;

    fn into_iter(self) -> Self::IntoIter {
        self.operations().iter()
    }
}

Unfortunately, this violates the orphan rule.

Xazax-hun commented 1 month ago

Probably should try the extension trait pattern.