Skip to main content Svelte Highlight v7.21.1

Move language preview

1. Coin module

modules, abilities, and resources
horizon-dark
module 0x1::Coin {
    struct Coin has key, store {
        value: u64,
    }

    public fun mint(value: u64): Coin {
        Coin { value }
    }

    public fun value(coin: &Coin): u64 {
        coin.value
    }
}
atom-one-dark
module 0x1::Coin {
    struct Coin has key, store {
        value: u64,
    }

    public fun mint(value: u64): Coin {
        Coin { value }
    }

    public fun value(coin: &Coin): u64 {
        coin.value
    }
}
github-dark
module 0x1::Coin {
    struct Coin has key, store {
        value: u64,
    }

    public fun mint(value: u64): Coin {
        Coin { value }
    }

    public fun value(coin: &Coin): u64 {
        coin.value
    }
}
dracula
module 0x1::Coin {
    struct Coin has key, store {
        value: u64,
    }

    public fun mint(value: u64): Coin {
        Coin { value }
    }

    public fun value(coin: &Coin): u64 {
        coin.value
    }
}
nord
module 0x1::Coin {
    struct Coin has key, store {
        value: u64,
    }

    public fun mint(value: u64): Coin {
        Coin { value }
    }

    public fun value(coin: &Coin): u64 {
        coin.value
    }
}
github
module 0x1::Coin {
    struct Coin has key, store {
        value: u64,
    }

    public fun mint(value: u64): Coin {
        Coin { value }
    }

    public fun value(coin: &Coin): u64 {
        coin.value
    }
}

2. Entry function

signer, address literals, and acquires
horizon-dark
module addr::Bank {
    use std::signer;

    public entry fun deposit(account: &signer, amount: u64) acquires Coin {
        let addr = signer::address_of(account);
        assert!(amount > 0, 1);
    }
}
atom-one-dark
module addr::Bank {
    use std::signer;

    public entry fun deposit(account: &signer, amount: u64) acquires Coin {
        let addr = signer::address_of(account);
        assert!(amount > 0, 1);
    }
}
github-dark
module addr::Bank {
    use std::signer;

    public entry fun deposit(account: &signer, amount: u64) acquires Coin {
        let addr = signer::address_of(account);
        assert!(amount > 0, 1);
    }
}
dracula
module addr::Bank {
    use std::signer;

    public entry fun deposit(account: &signer, amount: u64) acquires Coin {
        let addr = signer::address_of(account);
        assert!(amount > 0, 1);
    }
}
nord
module addr::Bank {
    use std::signer;

    public entry fun deposit(account: &signer, amount: u64) acquires Coin {
        let addr = signer::address_of(account);
        assert!(amount > 0, 1);
    }
}
github
module addr::Bank {
    use std::signer;

    public entry fun deposit(account: &signer, amount: u64) acquires Coin {
        let addr = signer::address_of(account);
        assert!(amount > 0, 1);
    }
}

3. Test-only functions

#[test], #[test_only], and #[expected_failure]
horizon-dark
module addr::Bank {
    #[test_only]
    use std::unit_test;

    #[test]
    fun test_deposit() {
        assert!(1 + 1 == 2, 0);
    }

    #[test]
    #[expected_failure]
    fun test_withdraw_too_much() {
        abort 1
    }
}
atom-one-dark
module addr::Bank {
    #[test_only]
    use std::unit_test;

    #[test]
    fun test_deposit() {
        assert!(1 + 1 == 2, 0);
    }

    #[test]
    #[expected_failure]
    fun test_withdraw_too_much() {
        abort 1
    }
}
github-dark
module addr::Bank {
    #[test_only]
    use std::unit_test;

    #[test]
    fun test_deposit() {
        assert!(1 + 1 == 2, 0);
    }

    #[test]
    #[expected_failure]
    fun test_withdraw_too_much() {
        abort 1
    }
}
dracula
module addr::Bank {
    #[test_only]
    use std::unit_test;

    #[test]
    fun test_deposit() {
        assert!(1 + 1 == 2, 0);
    }

    #[test]
    #[expected_failure]
    fun test_withdraw_too_much() {
        abort 1
    }
}
nord
module addr::Bank {
    #[test_only]
    use std::unit_test;

    #[test]
    fun test_deposit() {
        assert!(1 + 1 == 2, 0);
    }

    #[test]
    #[expected_failure]
    fun test_withdraw_too_much() {
        abort 1
    }
}
github
module addr::Bank {
    #[test_only]
    use std::unit_test;

    #[test]
    fun test_deposit() {
        assert!(1 + 1 == 2, 0);
    }

    #[test]
    #[expected_failure]
    fun test_withdraw_too_much() {
        abort 1
    }
}