Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
clippy, fmt, spellcheck
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
  • Loading branch information
xermicus committed Sep 27, 2023
commit 8f064c9312b0482d0cc5d880365d483a67809e93
7 changes: 5 additions & 2 deletions crates/ink/macro/src/storage/storable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
// limitations under the License.

use proc_macro2::TokenStream as TokenStream2;
use quote::{quote, quote_spanned};
use quote::{
quote,
quote_spanned,
};
use syn::spanned::Spanned;

/// `Storable` derive implementation for `struct` types.
Expand Down Expand Up @@ -78,7 +81,7 @@ fn storable_enum_derive(s: &synstructure::Structure) -> TokenStream2 {
s.ast().span(),
"Currently only enums with at most 256 variants are supported.",
)
.to_compile_error();
.to_compile_error()
}

let decode_body = s
Expand Down
28 changes: 7 additions & 21 deletions crates/storage/src/lazy/mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,11 @@
//! This mapping doesn't actually "own" any data.
//! Instead it is just a simple wrapper around the contract storage facilities.

use crate::traits::{
AutoKey,
Packed,
StorableHint,
StorageKey,
};
use crate::traits::{AutoKey, Packed, StorableHint, StorageKey};
use core::marker::PhantomData;
use ink_primitives::Key;
use ink_storage_traits::Storable;
use scale::{
Encode,
Error,
Input,
Output,
};
use scale::{Encode, Error, Input, Output};

/// A mapping of key-value pairs directly into contract storage.
///
Expand Down Expand Up @@ -151,7 +141,7 @@ where
/// Returns:
/// - `Ok(Some(_))` if the value was inserted successfully, containing the size in
/// bytes of the pre-existing value at the specified key if any.
/// - `Ok(None)` if the insert was succesfull but there was no pre-existing value.
/// - `Ok(None)` if the insert was successful but there was no pre-existing value.
/// - `Err(_)` if the encoded value exceeds the static buffer size.
#[inline]
pub fn try_insert<Q, R>(&mut self, key: Q, value: &R) -> ink_env::Result<Option<u32>>
Expand All @@ -160,7 +150,7 @@ where
R: Storable + scale::EncodeLike<V>,
{
if <R as Storable>::encoded_size(value) > ink_env::BUFFER_SIZE {
return Err(ink_env::Error::BufferTooSmall)
return Err(ink_env::Error::BufferTooSmall);
};

Ok(self.insert(key, value))
Expand Down Expand Up @@ -196,7 +186,7 @@ where
.expect("targets of less than 32bit pointer size are not supported; qed");

if encoded_length > ink_env::BUFFER_SIZE {
return Some(Err(ink_env::Error::BufferTooSmall))
return Some(Err(ink_env::Error::BufferTooSmall));
}

self.get(key).map(Ok)
Expand Down Expand Up @@ -246,7 +236,7 @@ where
.expect("targets of less than 32bit pointer size are not supported; qed");

if encoded_length > ink_env::BUFFER_SIZE {
return Some(Err(ink_env::Error::BufferTooSmall))
return Some(Err(ink_env::Error::BufferTooSmall));
}

self.take(key).map(Ok)
Expand Down Expand Up @@ -324,11 +314,7 @@ where
#[cfg(feature = "std")]
const _: () = {
use crate::traits::StorageLayout;
use ink_metadata::layout::{
Layout,
LayoutKey,
RootLayout,
};
use ink_metadata::layout::{Layout, LayoutKey, RootLayout};

impl<K, V, KeyType> StorageLayout for Mapping<K, V, KeyType>
where
Expand Down
4 changes: 3 additions & 1 deletion crates/storage/src/lazy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ where
return Err(ink_env::Error::BufferTooSmall)
};

Ok(self.set(value))
self.set(value);

Ok(())
}
}

Expand Down