cast<RK, RV> method

IMap<RK, RV> cast<RK, RV>()

Provides a view of this map as having RK keys and RV instances, if necessary.

If this map is already an IMap<RK, RV>, it is returned unchanged.

If this map contains only keys of type RK and values of type RV, all read operations will work correctly. If any operation exposes a non-RK key or non-RV value, the operation will throw instead.

Entries added to the map must be valid for both an IMap<K, V> and an IMap<RK, RV>.

Implementation

IMap<RK, RV> cast<RK, RV>() {
  Object result = _m.cast<RK, RV>(config);
  if (result is M<RK, RV>)
    return IMap._unsafe(result, config: config);
  else if (result is Map<RK, RV>)
    return IMap._(result, config: config);
  else
    throw AssertionError(result.runtimeType);
}