Skip to content

Commit 229c1a4

Browse files
authored
ref: Remove fail macro (#128)
1 parent 24a07e3 commit 229c1a4

File tree

3 files changed

+11
-21
lines changed

3 files changed

+11
-21
lines changed

src/decoder.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ impl<R: Read> StripHeaderReader<R> {
8484
if byte == b'\n' {
8585
HeaderState::PastHeader
8686
} else {
87-
fail!(io::Error::new(
87+
Err(io::Error::new(
8888
io::ErrorKind::InvalidData,
89-
"expected newline"
90-
));
89+
"expected newline",
90+
))?
9191
}
9292
}
9393
HeaderState::PastHeader => {
@@ -108,10 +108,10 @@ pub fn strip_junk_header(slice: &[u8]) -> io::Result<&[u8]> {
108108
let mut need_newline = false;
109109
for (idx, &byte) in slice.iter().enumerate() {
110110
if need_newline && byte != b'\n' {
111-
fail!(io::Error::new(
111+
Err(io::Error::new(
112112
io::ErrorKind::InvalidData,
113-
"expected newline"
114-
));
113+
"expected newline",
114+
))?
115115
} else if is_junk_json(byte) {
116116
continue;
117117
} else if byte == b'\r' {
@@ -136,7 +136,7 @@ fn decode_rmi(rmi_str: &str, val: &mut BitVec<u8, Lsb0>) -> Result<()> {
136136
b'+' => 62,
137137
b'/' => 63,
138138
_ => {
139-
fail!(Error::InvalidBase64(byte as char));
139+
return Err(Error::InvalidBase64(byte as char));
140140
}
141141
};
142142

@@ -190,11 +190,11 @@ pub fn decode_regular(rsm: RawSourceMap) -> Result<SourceMap> {
190190

191191
if nums.len() > 1 {
192192
if nums.len() != 4 && nums.len() != 5 {
193-
fail!(Error::BadSegmentSize(nums.len() as u32));
193+
return Err(Error::BadSegmentSize(nums.len() as u32));
194194
}
195195
src_id = (i64::from(src_id) + nums[1]) as u32;
196196
if src_id >= sources.len() as u32 {
197-
fail!(Error::BadSourceReference(src_id));
197+
return Err(Error::BadSourceReference(src_id));
198198
}
199199

200200
src = src_id;
@@ -204,7 +204,7 @@ pub fn decode_regular(rsm: RawSourceMap) -> Result<SourceMap> {
204204
if nums.len() > 4 {
205205
name_id = (i64::from(name_id) + nums[4]) as u32;
206206
if name_id >= names.len() as u32 {
207-
fail!(Error::BadNameReference(name_id));
207+
return Err(Error::BadNameReference(name_id));
208208
}
209209
name = name_id;
210210
}
@@ -330,7 +330,7 @@ pub fn decode_slice(slice: &[u8]) -> Result<DecodedMap> {
330330
/// Loads a sourcemap from a data URL
331331
pub fn decode_data_url(url: &str) -> Result<DecodedMap> {
332332
if !url.starts_with(DATA_PREAMBLE) {
333-
fail!(Error::InvalidDataUrl);
333+
return Err(Error::InvalidDataUrl);
334334
}
335335
let data_b64 = &url[DATA_PREAMBLE.len()..];
336336
let data = data_encoding::BASE64

src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@
4545
//!
4646
//! * `ram_bundle`: turns on RAM bundle support
4747
//!
48-
#[warn(missing_docs)]
49-
mod macros;
50-
5148
pub use crate::builder::SourceMapBuilder;
5249
pub use crate::decoder::{decode, decode_data_url, decode_slice};
5350
pub use crate::detector::{

src/macros.rs

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)