Added filename to top of .rs files
This commit is contained in:
parent
c4b3252845
commit
7d7a48b17d
@ -1,3 +1,4 @@
|
||||
// errors1.rs
|
||||
// This function refuses to generate text to be printed on a nametag if
|
||||
// you pass it an empty string. It'd be nicer if it explained what the problem
|
||||
// was, instead of just sometimes returning `None`. The 2nd test currently
|
||||
|
@ -1,3 +1,4 @@
|
||||
// errors2.rs
|
||||
// Say we're writing a game where you can buy items with tokens. All items cost
|
||||
// 5 tokens, and whenever you purchase items there is a processing fee of 1
|
||||
// token. A player of the game will type in how many items they want to buy,
|
||||
|
@ -1,3 +1,4 @@
|
||||
// errors3.rs
|
||||
// This is a program that is trying to use a completed version of the
|
||||
// `total_cost` function from the previous exercise. It's not working though--
|
||||
// we can't call the `try!` macro in the `main()` function! Why not?
|
||||
|
@ -1,3 +1,4 @@
|
||||
// errorsn.rs
|
||||
// This is a bigger error exercise than the previous ones!
|
||||
// You can do it!
|
||||
//
|
||||
|
@ -1,3 +1,4 @@
|
||||
// option1.rs
|
||||
// This example panics because the second time it calls `pop`, the `vec`
|
||||
// is empty, so `pop` returns `None`, and `unwrap` panics if it's called
|
||||
// on `None`. Handle this in a more graceful way than calling `unwrap`!
|
||||
|
@ -1,3 +1,4 @@
|
||||
// result1.rs
|
||||
// Make this test pass! Scroll down for hints :)
|
||||
|
||||
#[derive(PartialEq,Debug)]
|
||||
|
1
ex4.rs
1
ex4.rs
@ -1,3 +1,4 @@
|
||||
// ex4.rs
|
||||
// Make me compile!
|
||||
|
||||
fn something() -> Result<i32, std::num::ParseIntError> {
|
||||
|
@ -1,3 +1,4 @@
|
||||
// functions1.rs
|
||||
// Make me compile! Scroll down for hints :)
|
||||
|
||||
fn main() {
|
||||
|
@ -1,3 +1,4 @@
|
||||
// functions2.rs
|
||||
// Make me compile! Scroll down for hints :)
|
||||
|
||||
fn main() {
|
||||
|
@ -1,3 +1,4 @@
|
||||
// functions3.rs
|
||||
// Make me compile! Scroll down for hints :)
|
||||
|
||||
fn main() {
|
||||
|
@ -1,3 +1,4 @@
|
||||
// functions4.rs
|
||||
// Make me compile! Scroll down for hints :)
|
||||
|
||||
// This store is having a sale where if the price is an even number, you get
|
||||
|
@ -1,3 +1,4 @@
|
||||
// functions5.rs
|
||||
// Make me compile! Scroll down for hints :)
|
||||
|
||||
fn main() {
|
||||
|
@ -1,3 +1,5 @@
|
||||
// if1.rs
|
||||
|
||||
pub fn bigger(a: i32, b:i32) -> i32 {
|
||||
// Complete this function to return the bigger number!
|
||||
// Do not use:
|
||||
|
@ -1,3 +1,4 @@
|
||||
// macros1.rs
|
||||
// Make me compile! Scroll down for hints :)
|
||||
|
||||
macro_rules! my_macro {
|
||||
|
@ -1,3 +1,4 @@
|
||||
// macros2.rs
|
||||
// Make me compile! Scroll down for hints :)
|
||||
|
||||
fn main() {
|
||||
|
@ -1,3 +1,4 @@
|
||||
// macros3.rs
|
||||
// Make me compile, without taking the macro out of the module! Scroll down for hints :)
|
||||
|
||||
mod macros {
|
||||
|
@ -1,3 +1,4 @@
|
||||
// macros4.rs
|
||||
// Make me compile! Scroll down for hints :)
|
||||
|
||||
macro_rules! my_macro {
|
||||
|
@ -1,3 +1,4 @@
|
||||
// modules1.rs
|
||||
// Make me compile! Scroll down for hints :)
|
||||
|
||||
mod sausage_factory {
|
||||
|
@ -1,3 +1,4 @@
|
||||
// modules2.rs
|
||||
// Make me compile! Scroll down for hints :)
|
||||
|
||||
mod us_presidential_frontrunners {
|
||||
|
@ -1,3 +1,4 @@
|
||||
// move_semantics1.rs
|
||||
// Make me compile! Scroll down for hints :)
|
||||
|
||||
pub fn main() {
|
||||
|
@ -1,3 +1,4 @@
|
||||
// move_semantics2.rs
|
||||
// Make me compile without changing line 9! Scroll down for hints :)
|
||||
|
||||
pub fn main() {
|
||||
|
@ -1,3 +1,4 @@
|
||||
// move_semantics3.rs
|
||||
// Make me compile without adding new lines-- just changing existing lines!
|
||||
// (no lines with multiple semicolons necessary!)
|
||||
// Scroll down for hints :)
|
||||
|
@ -1,3 +1,4 @@
|
||||
// move_semantics4.rs
|
||||
// Refactor this code so that instead of having `vec0` and creating the vector
|
||||
// in `fn main`, we instead create it within `fn fill_vec` and transfer the
|
||||
// freshly created vector from fill_vec to its caller. Scroll for hints!
|
||||
|
@ -1,3 +1,4 @@
|
||||
// primitive_types1.rs
|
||||
// Fill in the rest of the line that has code missing!
|
||||
// No hints, there's no tricks, just get used to typing these :)
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// primitive_types2.rs
|
||||
// Fill in the rest of the line that has code missing!
|
||||
// No hints, there's no tricks, just get used to typing these :)
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// primitive_types3.rs
|
||||
// Create an array with at least 100 elements in it where the ??? is.
|
||||
// Scroll down for hints!
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// primitive_types4.rs
|
||||
// Get a slice out of Array a where the ??? is so that the `if` statement
|
||||
// returns true. Scroll down for hints!!
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// primitive_types5.rs
|
||||
// Destructure the `cat` tuple so that the println will work.
|
||||
// Scroll down for hints!
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// primitive_types6.rs
|
||||
// Use a tuple index to access the second element of `numbers`.
|
||||
// You can put this right into the `println!` where the ??? is.
|
||||
// Scroll down for hints!
|
||||
|
@ -1,3 +1,4 @@
|
||||
// arc1.rs
|
||||
// Make this code compile by filling in a value for `shared_numbers` where the
|
||||
// TODO comment is and creating an initial binding for `child_numbers`
|
||||
// somewhere. Try not to create any copies of the `numbers` Vec!
|
||||
|
@ -1,3 +1,4 @@
|
||||
// iterator3.rs
|
||||
// This is a bigger exercise than most of the others! You can do it!
|
||||
// Here is your mission, should you choose to accept it:
|
||||
// 1. Complete the divide function to get the first four tests to pass
|
||||
|
@ -1,3 +1,5 @@
|
||||
// iterators4.rs
|
||||
|
||||
pub fn factorial(num: u64) -> u64 {
|
||||
// Complete this function to return factorial of num
|
||||
// Do not use:
|
||||
|
@ -1,3 +1,4 @@
|
||||
// strings1.rs
|
||||
// Make me compile without changing the function signature! Scroll down for hints :)
|
||||
|
||||
fn main() {
|
||||
|
@ -1,3 +1,4 @@
|
||||
// strings2.rs
|
||||
// Make me compile without changing the function signature! Scroll down for hints :)
|
||||
|
||||
fn main() {
|
||||
|
@ -1,3 +1,4 @@
|
||||
// strings3.rs
|
||||
// Ok, here are a bunch of values-- some are `Strings`, some are `&strs`. Your
|
||||
// task is to call one of these two functions on each value depending on what
|
||||
// you think each value is. That is, add either `string_slice` or `string`
|
||||
|
@ -1,3 +1,4 @@
|
||||
// tests1.rs
|
||||
// Tests are important to ensure that your code does what you think it should do.
|
||||
// Tests can be run on this file with the following command:
|
||||
// rustc --test tests1.rs
|
||||
|
@ -1,3 +1,4 @@
|
||||
// tests2.rs
|
||||
// This test has a problem with it -- make the test compile! Make the test
|
||||
// pass! Make the test fail! Scroll down for hints :)
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// tests3.rs
|
||||
// This test isn't testing our function -- make it do that in such a way that
|
||||
// the test passes. Then write a second test that tests that we get the result
|
||||
// we expect to get when we call `is_even(5)`. Scroll down for hints!
|
||||
|
@ -1,3 +1,4 @@
|
||||
// tests4.rs
|
||||
// This test isn't testing our function -- make it do that in such a way that
|
||||
// the test passes. Then write a second test that tests that we get the result
|
||||
// we expect to get when we call `times_two` with a negative number.
|
||||
|
@ -1,3 +1,4 @@
|
||||
// threads1.rs
|
||||
// Make this compile! Scroll down for hints :) The idea is the thread
|
||||
// spawned on line 17 is completing jobs while the main thread is
|
||||
// monitoring progress until 10 jobs are completed. If you see 6 lines
|
||||
|
@ -1,3 +1,4 @@
|
||||
// variables1.rs
|
||||
// Make me compile! Scroll down for hints :)
|
||||
|
||||
fn main() {
|
||||
|
@ -1,3 +1,4 @@
|
||||
// variables2.rs
|
||||
// Make me compile! Scroll down for hints :)
|
||||
|
||||
fn main() {
|
||||
|
@ -1,3 +1,4 @@
|
||||
// variables3.rs
|
||||
// Make me compile! Scroll down for hints :)
|
||||
|
||||
fn main() {
|
||||
|
@ -1,3 +1,4 @@
|
||||
// variables4.rs
|
||||
// Make me compile! Scroll down for hints :)
|
||||
|
||||
fn main() {
|
||||
|
Loading…
Reference in New Issue
Block a user