Skip to content

Commit

Permalink
Fix a few minor issues from clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Skeletonxf committed Mar 11, 2024
1 parent b961e0b commit 9e43e78
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/differentiation/container_record/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ where
*
* This is a shorthand for `AsRecords::from(tensor.history(), TensorIterator::from(&tensor))`
*/
#[allow(clippy::type_complexity)]
pub fn iter_as_records<'b>(
&'b self,
) -> AsRecords<'a, TensorIterator<'b, (T, Index), RecordTensor<'a, T, S, D>, D>, T> {
Expand Down Expand Up @@ -529,6 +530,7 @@ where
*
* This is a shorthand for `AsRecords::from(matrix.history(), RowMajorIterator::from(&matrix))`
*/
#[allow(clippy::type_complexity)]
pub fn iter_row_major_as_records<'b>(
&'b self,
) -> AsRecords<'a, RowMajorIterator<'b, (T, Index), RecordMatrix<'a, T, S>>, T> {
Expand All @@ -543,6 +545,7 @@ where
* This is a shorthand for
* `AsRecords::from(matrix.history(), ColumnMajorIterator::from(&matrix))`
*/
#[allow(clippy::type_complexity)]
pub fn iter_column_major_as_records<'b>(
&'b self,
) -> AsRecords<'a, ColumnMajorIterator<'b, (T, Index), RecordMatrix<'a, T, S>>, T> {
Expand Down
2 changes: 1 addition & 1 deletion src/matrices/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ impl<T> Matrix<T> {
.into_iter()
.map(|slices| {
let rows = slices.len();
let columns = slices.get(0).map(|columns| columns.len()).unwrap_or(0);
let columns = slices.first().map(|columns| columns.len()).unwrap_or(0);
if columns == 0 {
// We may have allocated N rows but if each column in that row has no size
// our actual size is 0x0
Expand Down
4 changes: 2 additions & 2 deletions src/tensors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ where
* Returns a copy of the sole element in the 0 dimensional tensor.
*/
pub fn scalar(&self) -> T {
self.data.get(0).unwrap().clone()
self.data.first().expect("Tensors always have at least 1 element").clone()
}
}

Expand Down Expand Up @@ -1127,7 +1127,7 @@ where
*/
pub fn first(&self) -> T {
self.data
.get(0)
.first()
.expect("Tensors always have at least 1 element")
.clone()
}
Expand Down

0 comments on commit 9e43e78

Please sign in to comment.