Skip to content

tokyorust/trm6-ch1-all-the-strings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Challenge #1 - Allow &str and String

For Tokyo Rust Meetup's mini-hackathon on 2016-06-23.

Setup

For this task, any Rust nightly should be fine.

The challenge

It's simple! You have a Person struct whose new function only takes a String, but the cognitive overload of having to type "...".to_owned() or String::from("...") all the time when using it gets old real quick. Let's make the same function accept a &str as well.

Simply make cargo test pass without removing any tests and you're done! For convenience, cargo run already works and can be used for quick testing.

(Optional bonus challenge)

Make Person displayable, so that it can be used with println!() without accessing the name directly. Your main should then look as follows:

fn main() {
    let you = Person::new("Challenger");
    println!("Hello {}!", you);
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages