Skip to content
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

[stdlib] Add startswith() and endswith() to StringRef #2710

Closed

Conversation

fknfilewalker
Copy link

Also delegates String functions to StringRef

Signed-off-by: Lukas Lipp <llipp@cg.tuwien.ac.at>
@fknfilewalker fknfilewalker requested review from a team as code owners May 17, 2024 14:44
Signed-off-by: Lukas Lipp <llipp@cg.tuwien.ac.at>
Signed-off-by: Lukas Lipp <llipp@cg.tuwien.ac.at>
@fknfilewalker
Copy link
Author

fknfilewalker commented May 17, 2024

Especially for this PR it would be nice to have a way of creating a StringRef from a String with a left and right offset, without resorting to ptrs.
We could modify _strref_dangerous to accept bounds

var str_ref = String()._strref_dangerous(start, len)

In case of len > len(string) the result is clamped

See PR #2719

@JoeLoser JoeLoser self-assigned this May 21, 2024
fknfilewalker and others added 2 commits May 21, 2024 23:16
Signed-off-by: Lukas Lipp <15105596+fknfilewalker@users.noreply.github.com>
Signed-off-by: Lukas Lipp <llipp@cg.tuwien.ac.at>
@JoeLoser
Copy link
Collaborator

!sync

@modularbot modularbot added the imported-internally Signals that a given pull request has been imported internally. label May 21, 2024
@modularbot
Copy link
Collaborator

✅🟣 This contribution has been merged 🟣✅

Your pull request has been merged to the internal upstream Mojo sources. It will be reflected here in the Mojo repository on the nightly branch during the next Mojo nightly release, typically within the next 24-48 hours.

We use Copybara to merge external contributions, click here to learn more.

@modularbot modularbot added merged-internally Indicates that this pull request has been merged internally merged-externally Merged externally in public mojo repo labels May 22, 2024
modularbot added a commit that referenced this pull request May 23, 2024
…` (#40383)

[External] [stdlib] Add `startswith()` and `endswith()` to `StringRef`

Also delegates `String` functions to `StringRef`

ORIGINAL_AUTHOR=Lukas Lipp
<15105596+fknfilewalker@users.noreply.github.com>
PUBLIC_PR_LINK=#2710

Co-authored-by: Lukas Lipp <15105596+fknfilewalker@users.noreply.github.com>
Closes #2710
MODULAR_ORIG_COMMIT_REV_ID: cb7fd59c23fb5c655a1c0a1d6b5f7601306f6953
@modularbot
Copy link
Collaborator

Landed in bc4c5f7! Thank you for your contribution 🎉

@modularbot modularbot closed this May 23, 2024
martinvuyk pushed a commit to martinvuyk/mojo that referenced this pull request May 24, 2024
…` (#40383)

[External] [stdlib] Add `startswith()` and `endswith()` to `StringRef`

Also delegates `String` functions to `StringRef`

ORIGINAL_AUTHOR=Lukas Lipp
<15105596+fknfilewalker@users.noreply.github.com>
PUBLIC_PR_LINK=modularml#2710

Co-authored-by: Lukas Lipp <15105596+fknfilewalker@users.noreply.github.com>
Closes modularml#2710
MODULAR_ORIG_COMMIT_REV_ID: cb7fd59c23fb5c655a1c0a1d6b5f7601306f6953
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
imported-internally Signals that a given pull request has been imported internally. merged-externally Merged externally in public mojo repo merged-internally Indicates that this pull request has been merged internally
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants