mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
523 B
32 lines
523 B
4 years ago
|
## 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$
|
||
|
```
|