From bead16bfc729ed491354781f5eb4c19d61eb5782 Mon Sep 17 00:00:00 2001
From: Steve Klabnik
The Tradeoffs of Using
cloneThere's a tendency amongst many Rustaceans to prefer not to use
+data, and we'll be going into detail aboutcloneto fix -ownership problems due to its runtime cost. In Chapter XX on iterators, we'll -learn how to make this situation more efficient. For now, it's okay to copy a -few strings to keep making progress. We're only going to be making these +ownership problems due to its runtime cost. In Chapter 13 we'll learn how to +make this situation more efficient with iterators. For now, it's okay to copy +a few strings to keep making progress. We're only going to be making these copies once, and our filename and search string are both very small. It's better to have a working program that's a bit inefficient than try to hyper-optimize code on your first pass. As you get more experienced with Rust, @@ -355,7 +355,7 @@ by the standard library:unwrap_or_else. This method has similar beunwrapif theResultis anOkvalue: it returns the inner valueOkis wrapping. Unlikeunwrap, if the value is anErrvalue, this method calls a closure which is an anonymous function that we define and pass as an argument -tounwrap_or_else. We'll be covering closures in more detail in Chapter XX; +tounwrap_or_else. We'll be covering closures in more detail in Chapter 13; the important part to understand in this case is thatunwrap_or_elsewill pass the inner value of theErrto our closure in the parametererrthat appears between the vertical pipes. Usingunwrap_or_elselets us do some @@ -437,7 +437,7 @@ which we'll be covering in Chapter XX. For now, think of it like this: theErrortrait, but we're not specifying what particular type the return value will be. This gives us flexibility to return error values that may be of different types in different error cases.Boxis a smart pointer to heap -data, and we'll be going into detail aboutBoxin Chapter YY.Boxin Chapter 15.The second change is that we've removed our calls to
diff --git a/second-edition/print.html b/second-edition/print.html index cc4c29f02..65afc0e6e 100644 --- a/second-edition/print.html +++ b/second-edition/print.html @@ -10488,9 +10488,9 @@ code very straightforward.expectin favor of?, like we talked about in Chapter 9. Rather thanpanic!on an error, this will return the error value from the function we're in for the caller to handle.The Tradeoffs of Using
cloneThere's a tendency amongst many Rustaceans to prefer not to use
+data, and we'll be going into detail aboutcloneto fix -ownership problems due to its runtime cost. In Chapter XX on iterators, we'll -learn how to make this situation more efficient. For now, it's okay to copy a -few strings to keep making progress. We're only going to be making these +ownership problems due to its runtime cost. In Chapter 13 we'll learn how to +make this situation more efficient with iterators. For now, it's okay to copy +a few strings to keep making progress. We're only going to be making these copies once, and our filename and search string are both very small. It's better to have a working program that's a bit inefficient than try to hyper-optimize code on your first pass. As you get more experienced with Rust, @@ -10632,7 +10632,7 @@ by the standard library:unwrap_or_else. This method has similar beunwrapif theResultis anOkvalue: it returns the inner valueOkis wrapping. Unlikeunwrap, if the value is anErrvalue, this method calls a closure which is an anonymous function that we define and pass as an argument -tounwrap_or_else. We'll be covering closures in more detail in Chapter XX; +tounwrap_or_else. We'll be covering closures in more detail in Chapter 13; the important part to understand in this case is thatunwrap_or_elsewill pass the inner value of theErrto our closure in the parametererrthat appears between the vertical pipes. Usingunwrap_or_elselets us do some @@ -10714,7 +10714,7 @@ which we'll be covering in Chapter XX. For now, think of it like this: theErrortrait, but we're not specifying what particular type the return value will be. This gives us flexibility to return error values that may be of different types in different error cases.Boxis a smart pointer to heap -data, and we'll be going into detail aboutBoxin Chapter YY.Boxin Chapter 15.The second change is that we've removed our calls to
expectin favor of?, like we talked about in Chapter 9. Rather thanpanic!on an error, this will return the error value from the function we're in for the caller to handle.