endoli / message-format.rs

A MessageFormat implementation for Rust.
https://endoli.github.io/message-format.rs/
Apache License 2.0
12 stars 7 forks source link

Creating Args from owned values slice #10

Open dvtomas opened 5 years ago

dvtomas commented 5 years ago

Hi, I have a (for simplicity) &[(String, String)], where first String corresponds to Args::name and the second String corresponds to Args::Value (of type Value::Str). How do I convert this to the Args struct? I can't get around the pub prev: Option<&'a Args<'a>> reference hell in the Args struct.

That is, I need to implement

fn to_args(args: &[(String, String)]) -> Args {
  unimplemented!()
}

Any idea? Thank you.

Edit: It does not need to actually be a function. I'll use the resulting args to format the message immediately, so if there's a way to produce the Args inline, I'd be happy with that as well.