diff options
| author | Steve Klabnik <steve@steveklabnik.com> | 2014-10-09 15:17:22 -0400 |
|---|---|---|
| committer | Steve Klabnik <steve@steveklabnik.com> | 2014-10-29 11:43:07 -0400 |
| commit | 7828c3dd2858d8f3a0448484d8093e22719dbda0 (patch) | |
| tree | 2d2b106b02526219463d877d480782027ffe1f3f /src/libstd/io/extensions.rs | |
| parent | 3bc545373df4c81ba223a8bece14cbc27eb85a4d (diff) | |
| download | rust-7828c3dd2858d8f3a0448484d8093e22719dbda0.tar.gz rust-7828c3dd2858d8f3a0448484d8093e22719dbda0.zip | |
Rename fail! to panic!
https://github.com/rust-lang/rfcs/pull/221
The current terminology of "task failure" often causes problems when
writing or speaking about code. You often want to talk about the
possibility of an operation that returns a Result "failing", but cannot
because of the ambiguity with task failure. Instead, you have to speak
of "the failing case" or "when the operation does not succeed" or other
circumlocutions.
Likewise, we use a "Failure" header in rustdoc to describe when
operations may fail the task, but it would often be helpful to separate
out a section describing the "Err-producing" case.
We have been steadily moving away from task failure and toward Result as
an error-handling mechanism, so we should optimize our terminology
accordingly: Result-producing functions should be easy to describe.
To update your code, rename any call to `fail!` to `panic!` instead.
Assuming you have not created your own macro named `panic!`, this
will work on UNIX based systems:
grep -lZR 'fail!' . | xargs -0 -l sed -i -e 's/fail!/panic!/g'
You can of course also do this by hand.
[breaking-change]
Diffstat (limited to 'src/libstd/io/extensions.rs')
| -rw-r--r-- | src/libstd/io/extensions.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs index 57741db5ae2..a595921fcf7 100644 --- a/src/libstd/io/extensions.rs +++ b/src/libstd/io/extensions.rs @@ -70,7 +70,7 @@ impl<'r, R: Reader> Iterator<IoResult<u8>> for Bytes<'r, R> { /// /// * `n`: The value to convert. /// * `size`: The size of the value, in bytes. This must be 8 or less, or task -/// failure occurs. If this is less than 8, then a value of that +/// panic occurs. If this is less than 8, then a value of that /// many bytes is produced. For example, if `size` is 4, then a /// 32-bit byte representation is produced. /// * `f`: A callback that receives the value. @@ -109,7 +109,7 @@ pub fn u64_to_le_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T { /// /// * `n`: The value to convert. /// * `size`: The size of the value, in bytes. This must be 8 or less, or task -/// failure occurs. If this is less than 8, then a value of that +/// panic occurs. If this is less than 8, then a value of that /// many bytes is produced. For example, if `size` is 4, then a /// 32-bit byte representation is produced. /// * `f`: A callback that receives the value. @@ -146,7 +146,7 @@ pub fn u64_to_be_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T { /// * `data`: The buffer in which to extract the value. /// * `start`: The offset at which to extract the value. /// * `size`: The size of the value in bytes to extract. This must be 8 or -/// less, or task failure occurs. If this is less than 8, then only +/// less, or task panic occurs. If this is less than 8, then only /// that many bytes are parsed. For example, if `size` is 4, then a /// 32-bit value is parsed. pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 { @@ -156,7 +156,7 @@ pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 { assert!(size <= 8u); if data.len() - start < size { - fail!("index out of bounds"); + panic!("index out of bounds"); } let mut buf = [0u8, ..8]; |
