initial commit
This commit is contained in:
4
exercises/06_ticket_management/03_resizing/Cargo.toml
Normal file
4
exercises/06_ticket_management/03_resizing/Cargo.toml
Normal file
@@ -0,0 +1,4 @@
|
||||
[package]
|
||||
name = "resizing"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
17
exercises/06_ticket_management/03_resizing/src/lib.rs
Normal file
17
exercises/06_ticket_management/03_resizing/src/lib.rs
Normal file
@@ -0,0 +1,17 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn resizing() {
|
||||
let mut v = Vec::with_capacity(2);
|
||||
v.push(1);
|
||||
v.push(2); // max capacity reached
|
||||
assert_eq!(v.capacity(), 2);
|
||||
|
||||
v.push(3); // beyond capacity, needs to resize
|
||||
|
||||
// Can you guess what the new capacity will be?
|
||||
// Beware that the standard library makes no guarantees about the
|
||||
// algorithm used to resize the vector, so this may change in the future.
|
||||
assert_eq!(v.capacity(), todo!());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user