mirror of https://github.com/01-edu/public.git
panic review
This commit is contained in:
parent
e10771014a
commit
744915b06d
|
@ -2,20 +2,28 @@
|
||||||
|
|
||||||
### Instructions
|
### Instructions
|
||||||
|
|
||||||
Write a function that tries to open a file and panics if the file
|
Write a **function** that tries to open a file and panics if the file
|
||||||
doesn't exist
|
does not exist.
|
||||||
|
|
||||||
|
### Notions
|
||||||
|
|
||||||
### Expected Function
|
### Expected Function
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
pub fn open_file(s: &str) -> File {}
|
pub fn open_file(s: &str) -> File {
|
||||||
|
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
|
|
||||||
Here is a program to test your function
|
Here is a program to test your function:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
|
use std::fs::File;
|
||||||
|
use std::fs;
|
||||||
|
use panic::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let filename = "created.txt";
|
let filename = "created.txt";
|
||||||
File::create(filename).unwrap();
|
File::create(filename).unwrap();
|
||||||
|
|
Loading…
Reference in New Issue