Commit 6c063723 authored by Robin Freyler's avatar Robin Freyler

[lang2/macro] utils: add filter_map_ink_attributes

parent 45db92e6
......@@ -16,6 +16,7 @@
//! Contains general utilities for the ink! IR module.
use crate::ir;
use proc_macro2::Span;
use syn::{
parse::{
......@@ -73,6 +74,18 @@ where
attrs.into_iter().filter(|attr| is_ink_attribute(attr))
}
/// Yields back the filtered `#[ink(..)]` markers converted into their ink! form if any.
pub fn filter_map_ink_attributes<'a, I>(attrs: I) -> impl Iterator<Item = ir::Marker>
where
I: IntoIterator<Item = &'a syn::Attribute> + 'a,
{
use core::convert::TryFrom as _;
attrs
.into_iter()
.cloned()
.filter_map(|attr| ir::Marker::try_from(attr).ok())
}
/// Returns `true` if the attributes contain any `#[ink(..)]` markers.
pub fn has_ink_attributes<'a, I>(attrs: I) -> bool
where
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment