Skip to content

Commit 43bc590

Browse files
committed
try! -> ?
1 parent d5fa0bf commit 43bc590

File tree

5 files changed

+11
-7
lines changed

5 files changed

+11
-7
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@
55
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
66
# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
77
Cargo.lock
8+
9+
# cargo fmt
10+
*.bk

rustfmt.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
max_width = 120
2+
use_try_shorthand = true

src/hermite.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl<A> HermiteMatrix for Array<A, Ix2>
2929
where A: ImplQR + ImplSVD + ImplNorm + ImplSolve + ImplEigh + ImplCholesky + LinalgScalar + Float + Debug
3030
{
3131
fn eigh(self) -> Result<(Self::Vector, Self), LinalgError> {
32-
try!(self.check_square());
32+
self.check_square()?;
3333
let layout = self.layout()?;
3434
let (rows, cols) = self.size();
3535
let (w, a) = ImplEigh::eigh(layout, rows, self.into_raw_vec())?;
@@ -42,7 +42,7 @@ impl<A> HermiteMatrix for Array<A, Ix2>
4242
}
4343
fn ssqrt(self) -> Result<Self, LinalgError> {
4444
let (n, _) = self.size();
45-
let (e, v) = try!(self.eigh());
45+
let (e, v) = self.eigh()?;
4646
let mut res = Array::zeros((n, n));
4747
for i in 0..n {
4848
for j in 0..n {
@@ -52,10 +52,10 @@ impl<A> HermiteMatrix for Array<A, Ix2>
5252
Ok(v.dot(&res))
5353
}
5454
fn cholesky(self) -> Result<Self, LinalgError> {
55-
try!(self.check_square());
55+
self.check_square()?;
5656
let (n, _) = self.size();
5757
let layout = self.layout()?;
58-
let a = try!(ImplCholesky::cholesky(layout, n, self.into_raw_vec()));
58+
let a = ImplCholesky::cholesky(layout, n, self.into_raw_vec())?;
5959
let mut c = match layout {
6060
Layout::RowMajor => Array::from_vec(a).into_shape((n, n)).unwrap(),
6161
Layout::ColumnMajor => Array::from_vec(a).into_shape((n, n)).unwrap().reversed_axes(),

src/matrix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl<A> Matrix for Array<A, Ix2>
105105
let strides = self.strides();
106106
let k = min(n, m);
107107
let layout = self.layout()?;
108-
let (q, r) = try!(ImplQR::qr(layout, m, n, self.clone().into_raw_vec()));
108+
let (q, r) = ImplQR::qr(layout, m, n, self.clone().into_raw_vec())?;
109109
let (qa, ra) = if strides[0] < strides[1] {
110110
(Array::from_vec(q).into_shape((m, n)).unwrap().reversed_axes(),
111111
Array::from_vec(r).into_shape((m, n)).unwrap().reversed_axes())

src/square.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl<A> SquareMatrix for Array<A, Ix2>
4141
where A: ImplQR + ImplNorm + ImplSVD + ImplSolve + LinalgScalar + Float + Debug
4242
{
4343
fn inv(self) -> Result<Self, LinalgError> {
44-
try!(self.check_square());
44+
self.check_square()?;
4545
let (n, _) = self.size();
4646
let layout = self.layout()?;
4747
let a = ImplSolve::inv(layout, n, self.into_raw_vec())?;
@@ -52,7 +52,7 @@ impl<A> SquareMatrix for Array<A, Ix2>
5252
}
5353
}
5454
fn trace(&self) -> Result<Self::Scalar, LinalgError> {
55-
try!(self.check_square());
55+
self.check_square()?;
5656
let (n, _) = self.size();
5757
Ok((0..n).fold(A::zero(), |sum, i| sum + self[(i, i)]))
5858
}

0 commit comments

Comments
 (0)