-
Notifications
You must be signed in to change notification settings - Fork 13
Array should provide concrete-type element getters #273
Comments
|
Actually look at the code again, Having said that, I think it's a bit of an oversight that |
In GitLab by @WhyNotHugo on Apr 21, 2022, 12:19 Right, so it seems that if I want an array of non-variants, I need to use let es = Structure::from((command[0].clone(), command, true));
let mut a = Array::new(Signature::try_from("(sasb)").unwrap());
a.append(Value::Structure(es)).unwrap();
let props: Vec<(&str, Value)> = vec![
("ExecStart", Value::Array(a)),
]; Array genericsI think it really makes sense for let a : Array<MySignature> = vec!(...).into(); Note that an Signature macroThat aside, a macro for Both together would allow for something nice and simple (but also more compile-time validations): let a : Array<signature!("(sasb)")> = vec!(...).into |
but why don't use use a |
As I wrote, need to use |
And |
In GitLab by @WhyNotHugo on Apr 21, 2022, 18:45 I haven't been able to use Using a
Using I can't get an array of non-variants to work. I don't see how it's possible;
I think my idea was not clear: Array can be generic in the sense that one can
The generic parameter for array would just need to implement the |
Same thing about |
In GitLab by @WhyNotHugo on Apr 21, 2022, 21:13 Ooooh! This turned out to be so much simpler! let exec_start = (command[0].clone(), command, true);
let props: Vec<(&str, Value)> = vec![
("RemainAfterExit", remain_after_exit.into()),
("ExecStart", vec![exec_start].into()),
("ExitType", exit_type.to_string().into()),
]; |
In GitLab by @WhyNotHugo on Apr 20, 2022, 23:52
I need to create an array with a struct. I basically, want to do this:
But
Array
seems to assume that only Variants will be put into it, so I've only been able to construct arrays with variant(struct), which is not entirely the same.Is this possible an oversight in the API?
The text was updated successfully, but these errors were encountered: