I want to do as follows, but columns
is moved in both and_modify
and or_insert
(which we know are mutually exclusive), but the compiler will not allow it. Is there a way to still use the Entry
API, or should I refactor to something like match self.tables.get(&table_name)
, which the compiler will understand are mutually exclusive branches?
self.tables.entry(table_name)
.and_modify(|e| e.columns = Some(columns))
.or_insert(TableInfo{
policies: None,
columns: Some(columns),
});