You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since all the types in this crate only hold String this library copies more data than it needs it some situations (both serializing and deserializing). Probably the RPC overhead will make these copies insignificant in most cases, but this might be a micro optimization worth doing (measure first of course).
Two ways of doing this.
Replace String fields with Cow<str>. Easy to do but slightly more difficult to use when one do not care about copies.
Parameterize structs containing strings by the string type used.
pubstructCommand{/// Title of the command, like `save`.pubtitle:String,/// The identifier of the actual command handler.pubcommand:String,/// Arguments that the command handler should be/// invoked with.#[serde(skip_serializing_if="Option::is_none")]pubarguments:Option<Vec<Value>>,}pubstructCommand<S = String>{/// Title of the command, like `save`.pubtitle:S,/// The identifier of the actual command handler.pubcommand:S,/// Arguments that the command handler should be/// invoked with.#[serde(skip_serializing_if="Option::is_none")]pubarguments:Option<Vec<Value>>,}
Setting String as the default value may make this less of a breaking change but I am not sure how much it helps. This would make it possible to use Command<&str> or Command<Cow<str>>.
The text was updated successfully, but these errors were encountered:
Since all the types in this crate only hold
String
this library copies more data than it needs it some situations (both serializing and deserializing). Probably the RPC overhead will make these copies insignificant in most cases, but this might be a micro optimization worth doing (measure first of course).Two ways of doing this.
Replace
String
fields withCow<str>
. Easy to do but slightly more difficult to use when one do not care about copies.Parameterize structs containing strings by the string type used.
Setting
String
as the default value may make this less of a breaking change but I am not sure how much it helps. This would make it possible to useCommand<&str>
orCommand<Cow<str>>
.The text was updated successfully, but these errors were encountered: