forked from root/public
Augusto
3 years ago
4 changed files with 72 additions and 0 deletions
@ -0,0 +1,12 @@
|
||||
# This file is automatically @generated by Cargo. |
||||
# It is not intended for manual editing. |
||||
[[package]] |
||||
name = "to_url" |
||||
version = "0.1.0" |
||||
|
||||
[[package]] |
||||
name = "to_url_test" |
||||
version = "0.1.0" |
||||
dependencies = [ |
||||
"to_url", |
||||
] |
@ -0,0 +1,10 @@
|
||||
[package] |
||||
name = "to_url_test" |
||||
version = "0.1.0" |
||||
authors = ["Augusto <aug.ornelas@gmail.com>"] |
||||
edition = "2018" |
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html |
||||
|
||||
[dependencies] |
||||
to_url = { path = "../../../../rust-piscine-solutions/to_url"} |
@ -0,0 +1,19 @@
|
||||
// Define a function called `to_url` that takes a string and
|
||||
// substitutes every white-space with '%20'
|
||||
|
||||
use to_url::*; |
||||
|
||||
fn main() { |
||||
let s = "Hello, world!"; |
||||
println!("{} to be use as an url is {}", s, to_url(s)); |
||||
} |
||||
|
||||
#[cfg(test)] |
||||
mod test { |
||||
use super::*; |
||||
|
||||
#[test] |
||||
fn test_url() { |
||||
assert_eq!(to_url("this is my search"), "this%20is%20my%20search"); |
||||
} |
||||
} |
@ -0,0 +1,31 @@
|
||||
## to_url |
||||
|
||||
### Instructions |
||||
|
||||
Define a function called `to_url` that takes a string and substitutes every white-space with '%20' |
||||
|
||||
### Expected Function |
||||
|
||||
```rust |
||||
pub fn to_url(s: &str) -> String { |
||||
} |
||||
``` |
||||
|
||||
### Usage |
||||
|
||||
Here is a program to test your function. |
||||
|
||||
```rust |
||||
fn main() { |
||||
let s = "Hello, world!"; |
||||
println!("{} to be use as an url is {}", s, to_url(s)); |
||||
} |
||||
``` |
||||
|
||||
And its output |
||||
|
||||
```console |
||||
student@ubuntu:~/[[ROOT]]/test$ cargo run |
||||
Hello, world! to be use as an url is Hello,%20world! |
||||
student@ubuntu:~/[[ROOT]]/test$ |
||||
``` |
Loading…
Reference in new issue