hundreds-father-404
01/20/2021, 9:55 PM&str
instead of String
for a function's argument as it's more flexible. Same with using slices in args
In a couple of our workunit functions, like with_workunit
, we use String
. Do you know if that's for a particular reason?Same with using slices in argsIiuc,
&str
is a type of sliceenough-analyst-54434
01/20/2021, 9:58 PMwitty-crayon-22786
01/20/2021, 10:01 PM&str
, the caller might create a String
and throw it away, and the callee would need to copy itCow
type), but you only need them if the callee is not “definitely” going to take ownership&str
, String
), “borrowed”/“owned” dichotomy extends to a bunch of other types… including (&[T]
, Vec<T>
) , (Path
, PathBuf
), etcenough-analyst-54434
01/20/2021, 10:12 PM