[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::{
......@@ -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>
I: IntoIterator<Item = &'a syn::Attribute> + 'a,
use core::convert::TryFrom as _;
.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
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