Rust -Modern Procedural Language Program Writing
We are going to look at a modern procedural language, Rust (hps://www.rust-lang.org/) . Rust is a modern language, being rst developed in 2010 by Mozilla. It is meant to be a mul-paradigm language that focuses on safety.
We will be again looking at how Rust organizes code in a procedural way:
- Sequence
- Selec3. Itera4. Func
on on on
We will not be using the object-oriented or funconal aspects of the language.
Details
See the hw2-start.rs le for the funcons you need to implement. I have provided this to give you a starng point. You will need to save this le and rename it to hw2.rs so that the provided test-hw2.rs, that has the main funcon, can nd your soluon.
The provided test program will read from the input les and call your funcons then output your results. I have provided sample output les so you can check your results against these.
Grading
You will submit your single Rust le that only contains the implementaons of your funcons. Compiling
For compiling I will be using rustc only. This is mainly to ease how I can test. In general you would be using cargo build and a Cargo.toml le, but we arent doing that. If you are interested in learning more about that let me know and we can talk.Submit Assignment
https://canvas.vt.edu/courses/165509/assignments/1735037 1/3
2/11/23, 2:50 AM Homework 2
So this is what you will do
rustc test-hw2.rs
Do not add hw2.rs to the command. Then this will create an executable named test-hw2 which will want an
input
le and an output
le name. fi
./test-hw2 input.txt output.txt
This will read from input.txt and create, or erase, output.txt for the results. You can give any name for the
Files
See the les below for starter les and sample inputs and outputs.
hw2-start.rs (https://canvas.vt.edu/courses/165509/les/26828131?wrap=1)
(https://canvas.vt.edu/courses/165509/les/26828131/download?download_frd=1) test-hw2.rs (hps://canvas.vt.edu/courses/165509/les/26828132?wrap=1)
(https://canvas.vt.edu/courses/165509/les/26828132/download?download_frd=1) input.txt (hps://canvas.vt.edu/courses/165509/les/26828129?wrap=1)
(https://canvas.vt.edu/courses/165509/les/26828129/download?download_frd=1) - output.txt (hps://canvas.vt.edu/courses/165509/les/26828109?wrap=1)
(hps://canvas.vt.edu/courses/165509/les/26828109/download?download_frd=1) input-1.txt (hps://canvas.vt.edu/courses/165509/les/26828121?wrap=1)
(https://canvas.vt.edu/courses/165509/les/26828121/download?download_frd=1) - output-1.txt (hps://canvas.vt.edu/courses/165509/les/26828130?wrap=1)
(https://canvas.vt.edu/courses/165509/les/26828130/download?download_frd=1) input-2.txt (hps://canvas.vt.edu/courses/165509/les/26828122?wrap=1)
(https://canvas.vt.edu/courses/165509/les/26828122/download?download_frd=1) - output-2.txt (hps://canvas.vt.edu/courses/165509/les/26828123?wrap=1)
(https://canvas.vt.edu/courses/165509/les/26828123/download?download_frd=1) Restrictions
You may not use the built-in math ulies you are being asked to implement.
You may not use the OO features of Rust, i.e. you cannot make your own classes. You can use the OO features of the language for I/O etc.