From 7037833a79d30ef2d8f6c005ff7feb41f9c4037c Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Wed, 5 Jul 2023 16:22:39 +0200 Subject: [PATCH] fix scope warnings, fix #196 --- src/containers/hashmap.d | 14 +++++++------- src/containers/ttree.d | 14 ++++++++------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/containers/hashmap.d b/src/containers/hashmap.d index eb9c684..016f471 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; 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;