From 8109cbad97e33949391cc36739121669df90e964 Mon Sep 17 00:00:00 2001 From: Damian S Date: Tue, 20 Aug 2019 22:52:24 +0100 Subject: [PATCH] fix(errorsn.rs) Update the deprecated syntax by adding dyn to trait objectscloses #211 --- exercises/error_handling/errorsn.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/exercises/error_handling/errorsn.rs b/exercises/error_handling/errorsn.rs index ea1905ea..c2b16ce3 100644 --- a/exercises/error_handling/errorsn.rs +++ b/exercises/error_handling/errorsn.rs @@ -20,7 +20,7 @@ use std::fmt; use std::io; // PositiveNonzeroInteger is a struct defined below the tests. -fn read_and_validate(b: &mut io::BufRead) -> Result { +fn read_and_validate(b: &mut dyn io::BufRead) -> Result { let mut line = String::new(); b.read_line(&mut line); let num: i64 = line.trim().parse(); @@ -29,7 +29,7 @@ fn read_and_validate(b: &mut io::BufRead) -> Result } // This is a test helper function that turns a &str into a BufReader. -fn test_with_str(s: &str) -> Result> { +fn test_with_str(s: &str) -> Result> { let mut b = io::BufReader::new(s.as_bytes()); read_and_validate(&mut b) } @@ -98,7 +98,7 @@ enum CreationError { impl fmt::Display for CreationError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.write_str((self as &error::Error).description()) + f.write_str((self as &dyn error::Error).description()) } } @@ -190,7 +190,7 @@ impl error::Error for CreationError { // Another hint: under the hood, the `?` operator calls `From::from` -// on the error value to convert it to a boxed trait object, a Box, +// on the error value to convert it to a boxed trait object, a Box, // which is polymorphic-- that means that lots of different kinds of errors // can be returned from the same function because all errors act the same // since they all implement the `error::Error` trait.