fn_mut 0.1.0

fn_mut macro generates function which takes mutable reference to self and returns mutable reference.
Documentation
use std::collections::BTreeSet;
use regex::Regex;

pub struct Config<'a> {
    pub enable_self: bool,
    pub enable_output: bool,
    pub enable_attrs: BTreeSet<&'a str>
}

lazy_static! {
    static ref RE1: Regex = Regex::new(r#"([a-zA-Z0-9_]+)( = "([a-zA-Z0-9,_]*)")?"#).unwrap();
    static ref RE2: Regex = Regex::new(r#"[a-zA-Z0-9_]*"#).unwrap();
}

pub fn get_config<'a>(attrs: &'a str) -> Config<'a> {
    let mut config = Config {
        enable_self: true,
        enable_output: true,
        enable_attrs: BTreeSet::new()
    };
    for cap in RE1.captures_iter(attrs.as_ref()) {
        if let Some(m) = cap.get(1) {
            match m.as_str() {
                "disable_self" => config.enable_self = false,
                "disable_output" => config.enable_output = false,
                "enable_attrs" => {
                    if let Some(inner) = cap.get(3) {
                        for cap in RE2.captures_iter(inner.as_str()) {
                            if let Some(m) = cap.get(0) {
                                config.enable_attrs.insert(m.as_str());
                            }
                        }
                    }
                },
                other => panic!("attribute \"{}\" is not known", other)
            }
        }
    }
    config
}