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?hundreds-father-404
01/20/2021, 9:56 PMSame 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 PMwitty-crayon-22786
01/20/2021, 10:01 PMwitty-crayon-22786
01/20/2021, 10:02 PM&str, the caller might create a String and throw it away, and the callee would need to copy itwitty-crayon-22786
01/20/2021, 10:02 PMCow type), but you only need them if the callee is not “definitely” going to take ownershipwitty-crayon-22786
01/20/2021, 10:06 PM&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