Skip to content

Added proof for Vec::swap_remove - #23

Closed
MayureshJoshi25 wants to merge 1 commit into
mainfrom
verify/vec_swap_remove_usage
Closed

MayureshJoshi25 wants to merge 1 commit into
mainfrom
verify/vec_swap_remove_usage

Conversation

@MayureshJoshi25

Copy link
Copy Markdown
Collaborator

Please add a description of your PR.
If this is a solution to an open challenge, please explain your solution.

Don't forget to check our book to ensure your solution satisfy the overall
requirements as well as the challenge success criteria.

Resolves #ISSUE-NUMBER

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

pub fn verify_swap_remove() {
let mut vec = Vec::new();
// Creating an empty vector and then populating it with three arbitrary integers
for _ in 0..3 {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we hardcode the length as it's a magic number and have a comment explaining it?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay

let mut vec = Vec::new();
// Creating an empty vector and then populating it with three arbitrary integers
for _ in 0..3 {
vec.push(kani::any::<i32>());

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of pushing on non-deterministic integer at a time, can we directly create an array of a specific length and cover it into a vec?

const ARRAY_LEN: usize = 4;
let mut arr: [i32; ARRAY_LEN] = kani::any_array();
let mut vec = Vec::from(&mut arr)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the new proof on your side once please

Comment thread library/stdarch

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this from the commits

@stogaru stogaru closed this Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants