Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extern crate failure;
- use error::Error;
- use std::fs::File;
- type Result<T> = std::result::Result<T, Error>;
- mod error {
- use std::io::Error as IoError;
- use super::Result;
- #[derive(Debug, PartialEq/*<- ruh roh!*/)]
- pub enum Error {
- MyVariant(IoError),
- }
- impl Display...
- impl From<IoError> for Error...
- struct Foo {}
- impl Foo {
- fn example_fn(name: &str) -> Result<File> {
- match File::open(name)?
- }
- fn main() -> Result<()> {
- // ...
- Ok(())
- }
- #[test]
- fn test() {
- use super::{Error, Foo};
- let result = Foo::example_fn("foo.txt");
- // Verify Err(Error::MyVariant(std::io::Error(Simple(std::io::ErrorKind::NotFound)))) was received
- assert!(result == ???);
- }
Add Comment
Please, Sign In to add comment