Messages in this thread | | | Date | Wed, 3 Aug 2022 12:23:37 +0300 | From | Konstantin Shelekhin <> | Subject | Re: [PATCH v8 28/31] samples: add Rust examples |
| |
> Their types are different. One is for u8. The other is for UTF-8.
Yes, but:
+#[derive(Debug, Default)] +struct ModuleInfo { + type_: String, + license: String, + name: String, + author: Option<String>, + description: Option<String>, + alias: Option<String>, + params: Option<Group>, +}
[...]
+impl ModuleInfo { + fn parse(it: &mut token_stream::IntoIter) -> Self { + match key.as_str() { + "type" => info.type_ = expect_ident(it), + "name" => info.name = expect_byte_string(it), + "author" => info.author = Some(expect_byte_string(it)), + "description" => info.description = Some(expect_byte_string(it)), + "license" => info.license = expect_byte_string(it), + "alias" => info.alias = Some(expect_byte_string(it)), + "alias_rtnl_link" => { + info.alias = Some(format!("rtnl-link-{}", expect_byte_string(it))) + } + "params" => info.params = Some(expect_group(it)), + _ => panic!( + "Unknown key \"{}\". Valid keys are: {:?}.", + key, EXPECTED_KEYS + ), + }
In the the end all module parameters are String, so why not use &str in the API?
| |