What is the purpose of the StringSegment class?
In the package lib there is a class StringSegment for which the comments indicate that it is:
An optimized representation of a substring.
I was unaware of this particular class, until I discovered aspnet announcement #244, stating: .
Still, looking at the implementation of the StringSegment class, I fail to see what purpose it actually serves. I see a buffer, which I guess would indicate better manipulation on partial characters (the 'segment' part perhaps?). I also see several helper functions which are closely related - if not identical - in behaviour to those already available at regular strings, such as StartsWith/Endswith, Substring etc. The aspnet-core docs list these in full, but again this also lacks context on "why" it should be used.
So what exactly is the purpose of the StringSegment class and in which scenarios is it applicable to use it?
Is it useful to call the class in my application code, when I manipulate strings? Can we have an example, where it will be beneficial?