@@ -242,9 +242,9 @@ struct HashMap(K, V, Allocator = Mallocator, alias hashFunction = generateHash!K
242
242
/**
243
243
* Returns: a range of the keys in this map.
244
244
*/
245
- auto byKey (this This)() inout @trusted
245
+ auto byKey (this This)() inout @safe return scope
246
246
{
247
- return MapRange! (This, IterType.key)(cast (Unqual! (This)* ) &this );
247
+ return MapRange! (This, IterType.key)((() @trusted => cast (Unqual! (This)* ) &this )() );
248
248
}
249
249
250
250
/**
@@ -271,9 +271,9 @@ struct HashMap(K, V, Allocator = Mallocator, alias hashFunction = generateHash!K
271
271
/**
272
272
* Returns: a range of the values in this map.
273
273
*/
274
- auto byValue (this This)() inout @trusted
274
+ auto byValue (this This)() inout @safe return scope
275
275
{
276
- return MapRange! (This, IterType.value)(cast (Unqual! (This)* ) &this );
276
+ return MapRange! (This, IterType.value)((() @trusted => cast (Unqual! (This)* ) &this )() );
277
277
}
278
278
279
279
// / ditto
@@ -303,9 +303,9 @@ struct HashMap(K, V, Allocator = Mallocator, alias hashFunction = generateHash!K
303
303
* Returns: a range of the kev/value pairs in this map. The element type of
304
304
* this range is a struct with `key` and `value` fields.
305
305
*/
306
- auto byKeyValue (this This)() inout @trusted
306
+ auto byKeyValue (this This)() inout @safe return scope
307
307
{
308
- return MapRange! (This, IterType.both)(cast (Unqual! (This)* ) &this );
308
+ return MapRange! (This, IterType.both)((() @trusted => cast (Unqual! (This)* ) &this )() );
309
309
}
310
310
311
311
/**
@@ -431,7 +431,7 @@ private:
431
431
432
432
private :
433
433
434
- this (Unqual! (MapType)* hm)
434
+ this (Unqual! (MapType)* hm) @safe
435
435
{
436
436
this .hm = hm;
437
437
this .bucketIndex = 0 ;
@@ -665,7 +665,7 @@ version(emsi_containers_unittest) unittest
665
665
666
666
void someFunc (const scope ref HashMap! (string ,Foo ) map) @safe
667
667
{
668
- foreach (kv; map.byKeyValue ())
668
+ foreach (scope kv; map.byKeyValue ())
669
669
{
670
670
assert (kv.key == " foo" );
671
671
assert (kv.value.name == " Foo" );
0 commit comments