Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
StorageVec #2048
StorageVec #2048
Changes from 55 commits
2a7e168
23f925f
81a0ea6
7985f55
28e9be3
6b629db
a4a9093
f09060f
9c2a914
37ed447
51961a7
c42229d
8b059b3
082ded9
f6315fa
9ddaf7d
b22e00d
049b162
cbfbedc
75c414b
0da645a
da514b7
5f50e40
c04be39
3ad6fca
6bcfac1
859b0f6
7092230
ed76626
f90d304
b192910
3293293
7f23319
0ad4143
1c32489
9dc6a5c
a106f1c
f5b78c8
d242c9c
c9ce95f
578d9e3
27979d8
d9f17e3
f51da9f
57e4aef
6e65c39
5796f40
bcae640
a6b6ab8
bfae279
2ea82e7
06805d8
5adddc5
a1b3843
4b52750
3d62d03
ab32539
b13a0a3
d514b19
d6601a2
e2d1deb
f39495d
01eb00a
7468ad6
114e498
477b5b0
de75364
a73f659
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
What happens if I call
insert()
on an empty vector (i.e.len = 0
) and setindex = 0
? Wouldn'tlen - 1
cause a problem?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.
Good catch
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.
then it would underflow and panic right?
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.
But this should work, no? Shouldn't Inserting at index
len
(even iflen
is zero) exhibit the same behavior aspush
?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.
Nope, even rust panics here
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.
Hmm this is not panicking for me: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=c05a852a5b60fb1f13fa37bfd783b1f3
Even then, I think relying on an underflow to get a panic is an antipattern. The better practice is to do all your checking in separate code for safety and readability even if that means larger bytecode. The optimizer can then do its magic!
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.
As this PR is basically ready aside from this, I won't block the merge but I suggest you create "P: critical" issue tracking the above and hopefully we'll get to it asap.
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.
Ah sorry my bad I looked at the wrong thing, yeah i guess this works in rust.
After sway starts allowing methods to call other methods ill just add a if len == 0 before the while loop there to early return with a push