-
Notifications
You must be signed in to change notification settings - Fork 219
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
feat(stdlib): Vec type #1905
feat(stdlib): Vec type #1905
Conversation
let mut vector: Vec<Field> = Vec::new();
for i in 0..5 {
vector.push(i);
}
assert(vector.len() == 5); The type annotation is not necessary here, right? |
crates/nargo_cli/tests/test_data_ssa_refactor/vectors/src/main.nr
Outdated
Show resolved
Hide resolved
crates/nargo_cli/tests/test_data_ssa_refactor/slices/src/main.nr
Outdated
Show resolved
Hide resolved
Yeah it is unneeded I removed |
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.
Looks good. Once we fix slices in if statements we can add functions like map
as well.
Co-authored-by: jfecher <jake@aztecprotocol.com>
Co-authored-by: jfecher <jake@aztecprotocol.com>
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.
👍
Description
This PR utilizes the recent additions of mutable references and slices to create a Vec type.
Problem*
This is work towards resolving #1556
Summary*
I made a new type
struct Vec<T> { slice: [T] }
with a few builtin funcs that uses our slice builtins to implement a mutable vector type.If a user wants to update a slice they no longer have to use this syntax:
and can instead do this:
as the builtin Vec functions use mutable references. The Vec type is essentially a mutable wrapper over slices.
Documentation
This PR requires documentation updates when merged.
Additional Context
PR Checklist*
cargo fmt
on default settings.