Skip to main content

sym_can_contain_somehow

Function sym_can_contain_somehow 

Source
pub fn sym_can_contain_somehow(
    tag: SymStr,
    child: SymStr,
) -> Option<Option<SymStr>>
Expand description

The return type of this method is somewhat artisinal, as we have a three-way semantics:

  • None: There is no known structure that allows child as a descendant of tag
  • Some(None): child is directly allowed inside tag
  • Some(Some(inter_tag)): child is allowed inside inter_tag, which is allowed in tag

This could also (maybe more naturally?) be represented with a custom 3-valued enum. That said, I think it may be wiser to refactor the method entirely, always requiring a bool check, followed by an explicit request for the inner_tag name, which can be Option<SymStr>.