Ad
  • Custom User Avatar
  • Custom User Avatar

    Approved

  • Custom User Avatar

    python new test framework is required. updated in this fork

  • Custom User Avatar

    Python: Random tests are vulnerable to input modification

  • Custom User Avatar

    A reasonable optimizing compiler will produce the same machine code regardless of whether the variable is defined before the if-check or after it. Initializing local variables has no effects visible to callers so the compiler may freely reorder the code as it sees fit.

    The reason is just style and clarity. First of all, it's common to add preconditions to the start of a function. If there are no items, we already know the answer and we can return right away. Second, it's generally a good idea to keep the scope of variables as small as possible.

    Of course, in such a short function it doesn't really matter, but if a long function defines variable in the very beginning and uses it a lot later, can you be sure that there are no uses between? You have to carefully read through the whole function to check if there are other references.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Sorry for thr late reply, I didn't receive your comment :<

    Now it should be valid on 1.6

  • Custom User Avatar

    Oh yeah, I didn't notice that translation hadn't the latest language (maybe because I thought the 1.x should include every single version of Rust starting with 1.x). Fixed

  • Custom User Avatar

    Thanks. You must also select the latest version 1.6. Currently I see 1.x, which is weird.

  • Custom User Avatar

    Removed 'mut' from the string in question, now there shouldn't be any warnings here :)

  • Custom User Avatar

    In addition, there should not be any warnings:

    STDERR
    warning: variable does not need to be mutable
      --> src/lib.rs:56:17
       |
    56 |             let mut temp = a;
       |                 ----^^^^
       |                 |
       |                 help: remove this `mut`
       |
       = note: `#[warn(unused_mut)]` on by default
    
    warning: 1 warning emitted
    
  • Custom User Avatar

    There is require only for modifier in the comment:

        // TODO: Update this line to require that the owner be the one calling the contract
    

    But there's no require in the comment of sendGift buf only if:

        // TODO: We need to take coins from the account that sent this and gift them to the receiver address
        // only if the account that sent this has sufficient funds
        // If successful we'll broadcast the GiftSent event
    
  • Custom User Avatar

    This is just an old answer, so its had a long time to slowly accumulate votes. There's no generic upvote, you either vote for best practice or clever, and this is definitely NOT clever.

    It's also rust, which very few people truly understand (certainly including me) so many people don't know what they're looking at.

    That being said, I haven't ever used C and C++ only like 15 years ago, so this is more just general procedural language not really C/C++. But yeah, there are definitely more concise ways of doing this in rust, considering it's awesome methods on iterables.

  • Custom User Avatar

    Several upticks for 'Best Practices' which I don't understand. This is exactly a C/C++ solution transscribed into Rust, it works but is not idiomatic Rust. I'd therefore say NOT best practice.

  • Custom User Avatar
  • Loading more items...