From 38544a01929c4829e3ba61f5e9eb91b1b6d9e362 Mon Sep 17 00:00:00 2001 From: Luna Date: Tue, 10 Dec 2024 14:53:52 +0100 Subject: [PATCH] Make all nstring slicing operations inout --- source/numem/string.d | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/source/numem/string.d b/source/numem/string.d index 4faf5ed..a484d7f 100644 --- a/source/numem/string.d +++ b/source/numem/string.d @@ -387,32 +387,32 @@ public: D slices are short lived and may end up pointing to invalid memory if their string is modified. */ @trusted - const(T)[] opSlice(size_t start, size_t end) { - return cast(const(T)[])this.vec_[start..end]; + inout(T)[] opSlice(size_t start, size_t end) inout { + return cast(inout(T)[])this.vec_[start..end]; } /** Allows slicing the string to the full vector */ @trusted - const(T)[] opIndex() { - return cast(const(T)[])this.vec_[0..this.size()]; + inout(T)[] opIndex() inout { + return cast(inout(T)[])this.vec_[0..this.size()]; } /** Allows slicing the string to get a substring. */ @trusted - const(T)[] opIndex(size_t[2] slice) { - return cast(const(T)[])this.vec_[slice[0]..slice[1]]; + inout(T)[] opIndex(size_t[2] slice) inout { + return cast(inout(T)[])this.vec_[slice[0]..slice[1]]; } /** Allows getting a character from the string. */ @trusted - ref const(T) opIndex(size_t index) { - return cast(const(T))(this.vec_.data()[index]); + ref inout(T) opIndex(size_t index) inout { + return cast(inout(T))(this.vec_.data()[index]); } /** @@ -425,7 +425,7 @@ public: else size_t len = other.length; - return this.length == len && this.vec_[0..len] == other[0..len]; + return this.length == len && this[0..len] == other[0..len]; } /**