You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been working with ink! contracts and recently took a look at the latest version of OpenBrush. I noticed that the examples provided in OpenBrush appear to diverge from conventional Rust syntax and intuition, which can be unsettling for those familiar with the language. For the DSL to be widely accepted and user-friendly, I believe it should resemble idiomatic Rust as closely as possible.
To illustrate, let's use the 'Ownable' example. Here's the relevant code:
In this example, Ownable, PSP37,... appear abruptly, without a preceding use statement. The traits should be imported with use first.
Positioning of #[openbrush::implementation(Ownable, PSP37, PSP37Burnable, PSP37Mintable)]
Why is this line placed above mod ownable? Intuitively, it seems it should be applied to struct Contract, as it says impl Ownable,PSP37, PSP37Burnable, PSP37Mintable for Contract, doesn't it?
Explicit Declaration of Storage Fields Required by Trait Implementation
The way the storage field ownable is implicitly bound to the trait implementation is not immediately clear. I believe the relationship between the trait implementation and the storage field should be visually explicit, something like:
In Rust, a leading _ signals to the compiler to suppress unused item warnings. Overloading it with additional meaning can have unforeseen side effects. Moreover, the name Internal is a bit of a misnomer, and it may be worthwhile to consider a more descriptive name.
I have been working with
ink!
contracts and recently took a look at the latest version of OpenBrush. I noticed that the examples provided in OpenBrush appear to diverge from conventional Rust syntax and intuition, which can be unsettling for those familiar with the language. For the DSL to be widely accepted and user-friendly, I believe it should resemble idiomatic Rust as closely as possible.To illustrate, let's use the 'Ownable' example. Here's the relevant code:
There are several aspects of this example that seem to contravene Rust conventions and visual intuition:
Trait Usage Without Prior Import:
#[openbrush::implementation(Ownable, PSP37, PSP37Burnable, PSP37Mintable)]
In this example,
Ownable, PSP37,...
appear abruptly, without a preceding use statement. The traits should be imported withuse
first.Positioning of
#[openbrush::implementation(Ownable, PSP37, PSP37Burnable, PSP37Mintable)]
Why is this line placed above
mod ownable
? Intuitively, it seems it should be applied tostruct Contract
, as it saysimpl Ownable,PSP37, PSP37Burnable, PSP37Mintable for Contract
, doesn't it?Explicit Declaration of Storage Fields Required by Trait Implementation
The way the storage field
ownable
is implicitly bound to the trait implementation is not immediately clear. I believe the relationship between the trait implementation and the storage field should be visually explicit, something like:#[openbrush::implementation(Ownable(storage=ownable),...)]
Use of Leading
_
for Internal MethodsIn Rust, a leading
_
signals to the compiler to suppress unused item warnings. Overloading it with additional meaning can have unforeseen side effects. Moreover, the nameInternal
is a bit of a misnomer, and it may be worthwhile to consider a more descriptive name.default_impl(Trait)
This syntax is quite confusing, as
fn mint(&mut self) {}
outside animpl
block is not a valid Rust. A more conventional approach might be:The text was updated successfully, but these errors were encountered: