diff --git a/Libraries/LibGC/Ptr.h b/Libraries/LibGC/Ptr.h index fcbbb4b7586..5884b757256 100644 --- a/Libraries/LibGC/Ptr.h +++ b/Libraries/LibGC/Ptr.h @@ -6,6 +6,7 @@ #pragma once +#include #include #include @@ -238,4 +239,29 @@ struct Traits> : public DefaultTraits> { } }; +template +struct Formatter> : Formatter { + ErrorOr format(FormatBuilder& builder, GC::Ptr const& value) + { + return Formatter::format(builder, value.ptr()); + } +}; + +template +struct Formatter> : Formatter { + ErrorOr format(FormatBuilder& builder, GC::Ref const& value) + { + return Formatter::format(builder, *value); + } +}; + +template +requires(!HasFormatter) +struct Formatter> : Formatter { + ErrorOr format(FormatBuilder& builder, GC::Ref const& value) + { + return Formatter::format(builder, value.ptr()); + } +}; + }