Use `Cow` for input strings
Partially solving #16 (closed), using Cow
for input strings should noticeably reduce cases when you have to use dirty workarounds to pass borrowed values to tbot
.
To allowed owned strings, we need that all methods and input types store Cow<'a, str>
and take impl Into<Cow<'a, str>>
instead of &'a str
. There are a few consequences:
-
Input types can no longer be Copy
(methods are already non-Copy
, so this is a bit easier); -
Some types will have to cloned when using them several times, AsBorrowed
InteriorBorrow
solves this; -
For convenience tbot::markup::{markdown_v2,html}
should be convertible totypes::parameters::Text
. This can't be done without owned values because they generate final text on-demand.
Edited by Artem Starikov