Woo! Huge +1
I think bridging undersells the motivation, it's generally useful and was included in String Essentials. It allows users to avoid having their own hacky buffers for small contents and avoids an extra allocation for large contents.
Within the standard library, Float and Int portions do the hacky stack buffers thing.
@ravikandhadai could probably make good use of this in his logging efforts, as might the server-side loggers. @johannesweiss, does NIO or other server side projects have a use for directly initializing strings?
@tbkka, would this be useful for Swift protobuf?
Would this be because UTF8.CodeUnit is a trivial type? Worth stating explicitly.
The real motivation is that a failable closure would make the init failable. That would really hurt use sites, forcing them into an ugly anti-pattern the way failable withContiguousStorageIfAvailable
often does in practice.
edit: removed dangling text