Skip to main content

safe_index_optimised

Function safe_index_optimised 

Source
pub fn safe_index_optimised(m: Expression, idx: Literal) -> Option<Expression>
Expand description

This is the same as m[x] except when m is of the forms:

  • n[..], then it produces n[x] instead of n[..][x]
  • flatten(n), then it produces n[y] instead of flatten(n)[y], where y is the full index corresponding to flat index x

ยงReturns

  • Some(expr) if the safe indexing could be constructed
  • None if it could not be constructed (e.g. invalid index type)