annotate-snippets-rs
annotate-snippets-rs copied to clipboard
Support any `Display`, not just `&str`
This is split out of https://github.com/rust-lang/annotate-snippets-rs/issues/13#issuecomment-543321203
Input text doesn't have to be &str; it can be anything that can implement Display. This is especially useful when the origin source https://github.com/rust-lang/annotate-snippets-rs/pull/12#discussion_r322920987, so the intermediate allocation doesn't have to happen. Playing with take-two I think this dyn has negligible effect on runtime, the real killer to my time is dyn indirection to the span resolvers IIUC.
I think this would actually hurt performance because we can't directly Display into a location but generally need to do calculations on it, so we'd need to do to_string(), even if its a &str, meaning we'll do more allocations.