mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-05 10:19:18 +00:00
Merge branch 'master' of https://github.com/rust-lang/rustlings
This commit is contained in:
commit
ec782274a1
@ -34,7 +34,7 @@ This will install Rustlings and give you access to the `rustlings` command. Run
|
||||
|
||||
## Windows
|
||||
|
||||
First, set `ExecutionPolicy` to `RemoteSigned`:
|
||||
In PowerShell, set `ExecutionPolicy` to `RemoteSigned`:
|
||||
|
||||
```ps
|
||||
Set-ExecutionPolicy RemoteSigned
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
// An imaginary magical school has a new report card generation system written in rust!
|
||||
// An imaginary magical school has a new report card generation system written in Rust!
|
||||
// Currently the system only supports creating report cards where the student's grade
|
||||
// is represented numerically (e.g. 1.0 -> 5.5). However, the school also issues alphabetical grades
|
||||
// (A+ -> F-) and needs to be able to print both types of report card!
|
||||
// is represented numerically (e.g. 1.0 -> 5.5).
|
||||
// However, the school also issues alphabetical grades (A+ -> F-) and needs
|
||||
// to be able to print both types of report card!
|
||||
|
||||
// Make the necessary code changes to support alphabetical report cards, thereby making the second
|
||||
// test pass.
|
||||
// Make the necessary code changes to support alphabetical report cards, thereby making
|
||||
// the second test pass.
|
||||
|
||||
// I AM NOT DONE
|
||||
pub struct ReportCard {
|
||||
@ -15,7 +16,8 @@ pub struct ReportCard {
|
||||
|
||||
impl ReportCard {
|
||||
pub fn print(&self) -> String {
|
||||
format!("{} ({}) - achieved a grade of {}", &self.student_name, &self.student_age, &self.grade)
|
||||
format!("{} ({}) - achieved a grade of {}",
|
||||
&self.student_name, &self.student_age, &self.grade)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ fn main() {
|
||||
];
|
||||
for iter in 0..5 {
|
||||
let number_to_add: u16 = {
|
||||
((iter * 5) + 2) / (4 * 16)
|
||||
((iter * 1235) + 2) / (4 * 16)
|
||||
};
|
||||
|
||||
numbers[iter as usize] = Option::Some(number_to_add);
|
||||
|
||||
@ -4,6 +4,6 @@
|
||||
fn main() {
|
||||
let mut x = 3;
|
||||
println!("Number {}", x);
|
||||
x = 5;
|
||||
x = 5; // don't change this line
|
||||
println!("Number {}", x);
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// Make me compile! Execute the command `rustlings hint variables5` if you want a hint :)
|
||||
|
||||
fn main() {
|
||||
let number = "3";
|
||||
let number = "3"; // don't change this line
|
||||
println!("Number {}", number);
|
||||
let number = 3;
|
||||
println!("Number {}", number);
|
||||
|
||||
@ -68,7 +68,7 @@ then keyword 'let'.
|
||||
Constants types must also always be annotated.
|
||||
|
||||
Read more about constants under 'Differences Between Variables and Constants' in the book's section 'Variables and Mutability':
|
||||
https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html
|
||||
https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html#differences-between-variables-and-constants
|
||||
"""
|
||||
|
||||
# IF
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user