Skip to content

Commit

Permalink
fix: clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
austinabell committed Sep 17, 2023
1 parent 3392759 commit c0c8cf6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub fn abort() -> ! {

/// Reads the content of the `register_id`. If register is not used or the buffer is not large
/// enough, an error will be returned.
#[allow(clippy::result_unit_err)]
#[allow(clippy::result_unit_err, clippy::needless_pass_by_ref_mut)]
pub fn read_register(register_id: u64, buf: &mut [u8]) -> Result<usize, ()> {
let len = register_len(register_id).ok_or(())? as usize;
if buf.len() < len {
Expand Down
2 changes: 1 addition & 1 deletion src/types/heapless/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ impl<const N: usize> String<N> {
/// assert_eq!(s.pop(), None);
/// ```
pub fn pop(&mut self) -> Option<char> {
let ch = self.chars().rev().next()?;
let ch = self.chars().next_back()?;

// pop bytes that correspond to `ch`
for _ in 0..ch.len_utf8() {
Expand Down
6 changes: 2 additions & 4 deletions src/types/heapless/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ impl<T, const N: usize> Vec<T, N> {
debug_assert!(!self.is_empty());

self.len -= 1;
(self.buffer.get_unchecked_mut(self.len).as_ptr() as *const T).read()
(self.buffer.get_unchecked_mut(self.len).as_ptr()).read()
}

/// Appends an `item` to the back of the collection
Expand Down Expand Up @@ -920,9 +920,7 @@ impl<T, const N: usize> Iterator for IntoIter<T, N> {
type Item = T;
fn next(&mut self) -> Option<Self::Item> {
if self.next < self.vec.len() {
let item = unsafe {
(self.vec.buffer.get_unchecked_mut(self.next).as_ptr() as *const T).read()
};
let item = unsafe { self.vec.buffer.get_unchecked_mut(self.next).as_ptr().read() };
self.next += 1;
Some(item)
} else {
Expand Down
4 changes: 2 additions & 2 deletions tests/code_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ fn raw_contract_code_size_check() {
fn fungible_token_code_size_check() {
let size = check_example_size("smol_ft");

// 1416
assert!(size < 1500);
// 1806 in current Rust version
assert!(size < 2000);
}

0 comments on commit c0c8cf6

Please sign in to comment.