Rust provides a macro vec![]
to help you create Vectors.
This comes in quite handy when you need to initialize lists.
You are going to initialize empty buffers and list the first five numbers, or elements, of the Fibonacci sequence.
The Fibonacci sequence is a set of numbers where the next element is the sum of the prior two. We start the sequence at one. So the first two elements are 1 and 1.
count
zeroes.Create a function that creates a buffer of count
zeroes.
let my_buffer = create_buffer(5);
// [0, 0, 0, 0, 0]
Create a function that returns the first five numbers of the Fibonacci sequence.
Its first five elements are 1, 1, 2, 3, 5
let first_five = fibonacci();
// [1, 1, 2, 3, 5]
Sign up to Exercism to learn and master Rust with 98 exercises, and real human mentoring, all for free.