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.

43 lines
607 B

## panic
### Instructions
3 years ago
Write a **function** that tries to open a file and panics if the file
does not exist.
### Notions
### Expected Function
```rust
3 years ago
pub fn open_file(s: &str) -> File {
}
```
### Usage
3 years ago
Here is a program to test your function:
```rust
3 years ago
use std::fs::File;
use std::fs;
use panic::*;
fn main() {
let filename = "created.txt";
File::create(filename).unwrap();
let a = open_file(filename);
println!("{:?}", a);
fs::remove_file(filename).unwrap();
}
```
And its output:
```console
$ cargo run
File { fd: 3, path: "panic/a.txt", read: true, write: false }
$
```