Skip to content

nightly-2024-01-24: chore: convert vec references to slices (#4133)

Pre-release
Pre-release
Compare
Choose a tag to compare
@github-actions github-actions released this 24 Jan 02:19
· 1738 commits to master since this release
2645c10
# Description

Converts usages of `&Vec<T>` to `&[T]`

## Problem\*

Resolves https://github.com/noir-lang/noir/issues/679 

## Summary\*

`&Vec` can be dereferenced into `&[T]` whereas `&[T]` is more general.

In all but the following two cases, the type can simply be changed:

1. Both `clone` and `to_vec` perform a copy:
```rust
        VMStatus::Finished => Some((vm.get_registers().clone(), vm.get_memory().clone())),
        VMStatus::Finished => Some((vm.get_registers().clone(), vm.get_memory().to_vec())),
```

2. Both perform a match on the `Option`:
```rust
        self.name == name && (self.params.is_none() || self.params.as_ref() == Some(params))
        self.name == name && (self.params.is_none() || self.params.as_deref() == Some(params))
```

## Additional Context



## Documentation\*

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[Exceptional Case]** Documentation to be submitted in a separate
PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.