LibManual: Compare nodes by path

This makes them suited for hash map usage.
This commit is contained in:
kleines Filmröllchen 2023-07-02 13:26:34 +02:00 committed by Linus Groh
parent a9053618a8
commit f53aa959df
Notes: sideshowbarker 2024-07-17 21:26:19 +09:00

View file

@ -38,6 +38,24 @@ public:
// Finds a page via the help://man/<number>/<subsections...>/page URLs.
// This will automatically start discovering pages by inspecting the filesystem.
static ErrorOr<NonnullRefPtr<Node const>> try_find_from_help_url(URL const&);
bool operator==(Node const& other) const
{
if (auto this_path = this->path(), other_path = other.path();
!this_path.is_error() && !other_path.is_error()) {
return this_path.release_value() == other_path.release_value();
}
return false;
}
};
}
namespace AK {
template<typename T>
requires(IsBaseOf<Manual::Node, T>) struct Traits<T> : public GenericTraits<T> {
static unsigned hash(T p) { return Traits::hash(p.path()); }
};
}