LCOV - code coverage report

Current view
top level - src/converters - lazy_in_place_converter.dart
Test
lcov.info
Date
2024-11-13
Legend
Lines
hit
not hit
Branches
taken
not taken
# not executed
HitTotalCoverage
Lines2626100.0%
Functions00-
Branches00-
Each row represents a line of source code
LineBranchHitsSource code
1import 'converter.dart';
2import 'lazy_in_place_list.dart';
3import 'lazy_in_place_map.dart';
4
5/// This converter converts items in lists and maps **in place**. It avoids
6/// creating a copy of the data to hold the conversion result. Additionally,
7/// items in the list/map are lazily converted, i.e. only upon accessing them.
8final class LazyInPlaceConverter extends Converter {
93 const LazyInPlaceConverter(this.converter) : super();
10
11 final Converter converter;
12
131 @override
143 Cast<T> value<T>() => converter.value<T>();
15
161 @override
171 Cast<List<T>> list<T>([Cast<T>? cast]) {
182 final op = cast ?? value<T>();
195 return Converter.isIdentity<T>(op) ? converter.list<T>(op) : _toList(op);
201 }
21
221 @override
231 Cast<Set<T>> set<T>([Cast<T>? cast]) {
242 final op = cast ?? value<T>();
255 return Converter.isIdentity<T>(op) ? converter.set<T>(op) : _toSet(op);
261 }
27
281 @override
291 Cast<Map<K, V>> map<K, V>({Cast<K>? kcast, Cast<V>? vcast}) {
303 final kop = kcast ?? value<K>(), vop = vcast ?? value<V>();
313 return (!Converter.isIdentity<K>(kop) || Converter.isIdentity<V>(vop))
323 ? converter.map<K, V>(kcast: kop, vcast: vop)
332 : _toMap(vop);
341 }
35
362 static Cast<List<T>> _toList<T>(Cast<T> cast) =>
373 (x) => LazyInPlaceList(x, cast);
38
392 static Cast<Set<T>> _toSet<T>(Cast<T> cast) =>
404 (x) => (x as Iterable).map(cast).toSet();
41
422 static Cast<Map<K, V>> _toMap<K, V>(Cast<V> vcast) =>
433 (x) => LazyInPlaceMap(x, vcast);
44}
Choose Features