anders429 / substring Goto Github PK
View Code? Open in Web Editor NEWA substring method for string types.
License: Apache License 2.0
A substring method for string types.
License: Apache License 2.0
Should be able to exclude len() for example:
string.substring_len(3)
Could be a shorthand for string.substring(3, string.len())
There are different kinds of substrings that can be supported by this library. Currently, the implementation supports substrings with respect to char
s, but some users will likely want substrings with respect to graphemes instead. Word and sentence substrings could also be supported using the relevant unicode standards.
Altogether, I see the following substring variants being possible:
Since we are already looking at a breaking change with #9, the Substring
trait can be renamed to CharSubstring
(so there is no ambiguity between substring variants). The unicode-segmentation variants (grapheme, word, and sentence) can be guarded behind a unicode
feature (or perhaps separate features for each?). The byte variant can be held off on for now, since it really isn't needed and presents issues with properly-formed strings.
This solution will give maximum clarity as to what this crate offers, and will give flexibility for users to choose from the various types of substrings offered.
The parameters for the substring
method can be changed to a RangeBounds. This will allow for providing inclusive end points, as well as providing unbounded start/end points (as has been requested in #5).
This would be a breaking change, but I think it will make the library a bit easier to use. I would rather do this than introduce several methods for each specific case. It will also raise MSRV to match what is required for RangeBounds
.
Support for negative indexing would be helpful.
Example:
string.substring(-5, -3)
On the string "hello world" this would return "wo".
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.