-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move String
into std-lib
#4710
Move String
into std-lib
#4710
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a String
, it's just Bytes
with convenience methods. I don't see the point of standardizing it if we're not standardizing the actual behavior of characters and unicode handling in Sway, which this doesn't do.
All it does is add overhead and breakage to our later attempts at doing that. So unless there is a good reason I don't see to do it, I don't think we should do it.
This is pulled from the Sway-Libs String which addresses this specific problem. Until we have char there is no way to 1. convert a The intent to move it into the std-lib was based on the fact that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The standard library should consist of components that can be used directly or libraries can stitch together.
The string is a convenience type, a wrapper, which is a library rather than some atomic component.
I do not believe that this type should be in the standard library for that reason.
It's nice for convenience of importing but it's not much to point at the libs repo.
Just to throw an idea in here, which I'm not really a fan of, we could have core
, std
and XYZ
which would contain these convenience types / mix between a component and a library.
That creates a grey area for the amount of functionality between a lib and component and it probably does not entirely eliminate the libs repo so it fragments the content even more.
Convenience types should indeed belong in user packages, I think Rust's approach of doing it with things like But this isn't really the reason not to add this. Rather, this convenience string type will not be what we settle on when proper strings actually get standardized. Because it does not actually solve the Unicode problem, it just sidesteps it by pretending a collection of bytes is a Unicode string without checking, and doesn't actually let you manipulate code points in any meaningful way. As you say, this isn't actually possible to implement without I don't think it's proper to standardize an interface we know we will break in the near future. |
By this logic, the Rust The main problem is that any Fundamentally, yes, in it's current state the |
## Description Create a minimal, forward compatible unicode string type that only accepts ASCII input and doesn't provide mutation of codepoints. This should provide Sway-Standards with a proper black box type to use while still giving us a good platform to later implement a proper, `char` based unicode string without compatibility issues. Follow-up from #4710 ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [x] I have added tests that prove my fix is effective or that my feature works. - [x] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [ ] I have requested a review from the relevant team or maintainers.
Description
The
String
type is more of a primitive type than a library that provides special functionality. It should live in the std-lib.Checklist
Breaking*
orNew Feature
labels where relevant.