diff options
Diffstat (limited to 'src/hir/hir.cpp')
-rw-r--r-- | src/hir/hir.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/hir/hir.cpp b/src/hir/hir.cpp index 3a8ab95b..5177f101 100644 --- a/src/hir/hir.cpp +++ b/src/hir/hir.cpp @@ -8,6 +8,7 @@ * HIR type helper code */ #include "hir.hpp" +#include <algorithm> namespace HIR { ::std::ostream& operator<<(::std::ostream& os, const ::HIR::Literal& v) @@ -45,6 +46,14 @@ namespace HIR { } } +const ::HIR::Enum::Variant* ::HIR::Enum::get_variant(const ::std::string& name) const +{ + auto it = ::std::find_if(m_variants.begin(), m_variants.end(), [&](const auto& x){ return x.first == name; }); + if( it == m_variants.end() ) + return nullptr; + return &it->second; +} + namespace { bool matches_genericpath(const ::HIR::GenericParams& params, const ::HIR::GenericPath& left, const ::HIR::GenericPath& right, ::HIR::t_cb_resolve_type ty_res, bool expand_generic); |