diff --git a/src/containers/hashmap.d b/src/containers/hashmap.d index eb9c684..52709ca 100644 --- a/src/containers/hashmap.d +++ b/src/containers/hashmap.d @@ -242,9 +242,9 @@ struct HashMap(K, V, Allocator = Mallocator, alias hashFunction = generateHash!K /** * Returns: a range of the keys in this map. */ - auto byKey(this This)() inout @trusted + auto byKey(this This)() inout @safe return scope { - return MapRange!(This, IterType.key)(cast(Unqual!(This)*) &this); + return MapRange!(This, IterType.key)((() @trusted => cast(Unqual!(This)*) &this)()); } /** @@ -271,9 +271,9 @@ struct HashMap(K, V, Allocator = Mallocator, alias hashFunction = generateHash!K /** * Returns: a range of the values in this map. */ - auto byValue(this This)() inout @trusted + auto byValue(this This)() inout @safe return scope { - return MapRange!(This, IterType.value)(cast(Unqual!(This)*) &this); + return MapRange!(This, IterType.value)((() @trusted => cast(Unqual!(This)*) &this)()); } /// ditto @@ -303,9 +303,9 @@ struct HashMap(K, V, Allocator = Mallocator, alias hashFunction = generateHash!K * Returns: a range of the kev/value pairs in this map. The element type of * this range is a struct with `key` and `value` fields. */ - auto byKeyValue(this This)() inout @trusted + auto byKeyValue(this This)() inout @safe return scope { - return MapRange!(This, IterType.both)(cast(Unqual!(This)*) &this); + return MapRange!(This, IterType.both)((() @trusted => cast(Unqual!(This)*) &this)()); } /** @@ -431,7 +431,7 @@ private: private: - this(Unqual!(MapType)* hm) + this(Unqual!(MapType)* hm) @safe { this.hm = hm; this.bucketIndex = 0; @@ -665,7 +665,7 @@ version(emsi_containers_unittest) unittest void someFunc(const scope ref HashMap!(string,Foo) map) @safe { - foreach (kv; map.byKeyValue()) + foreach (scope kv; map.byKeyValue()) { assert (kv.key == "foo"); assert (kv.value.name == "Foo"); diff --git a/src/containers/ttree.d b/src/containers/ttree.d index 5e7e908..da1896f 100644 --- a/src/containers/ttree.d +++ b/src/containers/ttree.d @@ -899,7 +899,7 @@ private: return r; } - void rotateLeft(ref Node* root, AllocatorType allocator) @safe + void rotateLeft(ref Node* root, AllocatorType allocator) @trusted { Node* newRoot; if (right.left !is null && right.right is null) @@ -927,7 +927,7 @@ private: cleanup(newRoot, root, allocator); } - void rotateRight(ref Node* root, AllocatorType allocator) @safe + void rotateRight(ref Node* root, AllocatorType allocator) @trusted { Node* newRoot; if (left.right !is null && left.left is null) @@ -959,10 +959,12 @@ private: { if (newRoot.parent !is null) { - if (newRoot.parent.right is &this) - newRoot.parent.right = newRoot; - else - newRoot.parent.left = newRoot; + (() @trusted { + if (newRoot.parent.right is &this) + newRoot.parent.right = newRoot; + else + newRoot.parent.left = newRoot; + })(); } else root = newRoot;