mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:44:58 +00:00
LibManual: Compare nodes by path
This makes them suited for hash map usage.
This commit is contained in:
parent
a9053618a8
commit
f53aa959df
1 changed files with 18 additions and 0 deletions
|
@ -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()); }
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue