wrap-cli
wrap-cli copied to clipboard
wasm-rs: Codegen Types Should Use `str` Instead of `String`
Currently the rust codegen uses String instead of str for all of its types. This is needless, since these types should be expected to be "static" and immutable.
An example of what using String looks like from a user's perspective:
let response = HttpQuery::get(&http_query::InputGet {
url: url,
request: Some(HttpRequest {
response_type: HttpResponseType::TEXT,
headers: Some(vec!(HttpHeader {
key: String::from("user-agent"),
value: String::from("HttpDemo")
})),
url_params: Some(vec!(HttpUrlParam {
key: String::from("dummyQueryParam"),
value: String::from("20")
})),
body: Some(String::from(""))
})
});
And what it could look like if str was used:
let response = HttpQuery::get(&http_query::InputGet {
url: url,
request: Some(HttpRequest {
response_type: HttpResponseType::TEXT,
headers: Some(vec!(HttpHeader {
key: "user-agent",
value: "HttpDemo"
})),
url_params: Some(vec!(HttpUrlParam {
key: "dummyQueryParam",
value: "20"
}))
})
});