diff --git a/stdlib/src/utils/stringref.mojo b/stdlib/src/utils/stringref.mojo index ddc9559ff1..0d1ede078e 100644 --- a/stdlib/src/utils/stringref.mojo +++ b/stdlib/src/utils/stringref.mojo @@ -15,7 +15,7 @@ from bit import count_trailing_zeros from builtin.dtype import _uint_type_of_width -from collections.string import _atol, _isspace, _StringRepr +from collections.string import _atol, _isspace from hashlib._hasher import _HashableWithHasher, _Hasher from memory import UnsafePointer, memcmp, pack_bits from memory.memory import _memcmp_impl_unconstrained @@ -404,14 +404,7 @@ struct StringRef( Returns: The String representation of the StringRef. """ - var output = String() - var to_str = str(self) - - output.write("StringRef(") - _StringRepr(to_str).write_to(output) - output.write(")") - _ = to_str - return output + return String.write("StringRef(", repr(str(self)), ")") @no_inline fn write_to[W: Writer](self, inout writer: W):