AK: Forbid from_utf8 and from_deprecated_{...} with unintended types

Calling `from_utf8` with a DeprecatedString will hide the fact that we
have a DeprecatedString, while using `from_deprecated_string` with a
StringView will silently and needlessly allocate a DeprecatedString,
so let's forbid that.
This commit is contained in:
Hendiadyoin1 2023-06-11 19:49:02 +02:00 committed by Jelle Raaijmakers
commit ca0106ba1d
Notes: sideshowbarker 2024-07-17 08:35:21 +09:00
3 changed files with 14 additions and 1 deletions

View file

@ -1047,7 +1047,7 @@ ErrorOr<String> mkdtemp(Span<char> pattern)
return Error::from_errno(errno);
}
return String::from_utf8({ path, strlen(path) });
return String::from_utf8(StringView { path, strlen(path) });
}
ErrorOr<void> rename(StringView old_path, StringView new_path)