1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use proc_macro_error::ResultExt;
use syn::parse::{ParseStream, Result};
use syn::{parenthesized, Ident, LitBool};

use deprecated::utils::parse_eq_and_lit_str;
use util::TREAT_NONE_AS_NULL_NOTE;

pub fn parse_changeset_options(name: Ident, input: ParseStream) -> Result<(Ident, LitBool)> {
    if input.is_empty() {
        abort!(name.span(), "unexpected end of input, expected parentheses");
    }

    let content;
    parenthesized!(content in input);

    let name: Ident = content.parse()?;
    let name_str = name.to_string();

    if name_str != "treat_none_as_null" {
        abort!(name.span(), "expected `treat_none_as_null`");
    }

    Ok((name.clone(), {
        let lit_str = parse_eq_and_lit_str(name, &content, TREAT_NONE_AS_NULL_NOTE)?;
        lit_str.parse().unwrap_or_abort()
    }))
}