-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix scope warnings, fix #196 #197
base: master
Are you sure you want to change the base?
Conversation
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)()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're returning &this
, not this
, so the correct lifetime annotation here is return ref
(i.e., return
, since the ref
on this
is implicit), not return scope
.
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)()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
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)()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
@@ -431,7 +431,7 @@ private: | |||
|
|||
private: | |||
|
|||
this(Unqual!(MapType)* hm) | |||
this(Unqual!(MapType)* hm) @safe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The compiler should be able to infer this.
@@ -899,7 +899,7 @@ private: | |||
return r; | |||
} | |||
|
|||
void rotateLeft(ref Node* root, AllocatorType allocator) @safe | |||
void rotateLeft(ref Node* root, AllocatorType allocator) @trusted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this need to be @trusted
? How do we know that what it's doing is memory safe? Please add a comment for future maintainers.
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
newRoot.parent.right = newRoot; | ||
else | ||
newRoot.parent.left = newRoot; | ||
(() @trusted { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
No description provided.