Skip to content

Latest commit

 

History

History
43 lines (34 loc) · 755 Bytes

File metadata and controls

43 lines (34 loc) · 755 Bytes
title taxonomy process
Dynamic Types
category
docs
twig
true

[TOC]

Dynamic types

Dynamic types are types which can be defined and used solely within a Rune script. They provide the ability to structure data and associate functions with it.

The following is a quick example of a struct:

struct Person {
    name,
}

impl Person {
    fn greet(self) {
        println!("Greetings from {}, and good luck with this section!", self.name);
    }
}

pub fn main() {
    let person = Person {
        name: "John-John Tedro",
    };

    person.greet();
}
$> cargo run --bin rune -- run scripts/book/dynamic_types/greeting.rn
Greetings from John-John Tedro, and good luck with this section!
== () (2.7585ms)