mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 10:18:13 +00:00
AK: Convert AK::Format formatting helpers to returning ErrorOr<void>
This isn't a complete conversion to ErrorOr<void>, but a good chunk. The end goal here is to propagate buffer allocation failures to the caller, and allow the use of TRY() with formatting functions.
This commit is contained in:
parent
008355c222
commit
216e21a1fa
87 changed files with 450 additions and 448 deletions
|
@ -201,9 +201,9 @@ struct B {
|
|||
};
|
||||
template<>
|
||||
struct AK::Formatter<B> : Formatter<StringView> {
|
||||
void format(FormatBuilder& builder, B)
|
||||
ErrorOr<void> format(FormatBuilder& builder, B)
|
||||
{
|
||||
Formatter<StringView>::format(builder, "B");
|
||||
return Formatter<StringView>::format(builder, "B");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -283,7 +283,7 @@ struct C {
|
|||
};
|
||||
template<>
|
||||
struct AK::Formatter<C> : AK::Formatter<FormatString> {
|
||||
void format(FormatBuilder& builder, C c)
|
||||
ErrorOr<void> format(FormatBuilder& builder, C c)
|
||||
{
|
||||
return AK::Formatter<FormatString>::format(builder, "C(i={})", c.i);
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ TEST_CASE(long_long_regression)
|
|||
|
||||
StringBuilder builder;
|
||||
AK::FormatBuilder fmtbuilder { builder };
|
||||
fmtbuilder.put_i64(0x0123456789abcdefLL);
|
||||
MUST(fmtbuilder.put_i64(0x0123456789abcdefLL));
|
||||
|
||||
EXPECT_EQ(builder.string_view(), "81985529216486895");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue