Skip to main content

Passing arguments

Beginner
Tutorial

Overview

Arrays

Rust uses the vec type to represent vectors (sequences, lists, arrays).

let numbers = vec![0, 1, 2, 3 ];
#[query]
fn get_numbers(numbers: Vec<u32>) -> Vec<u32> {
numbers
}

Variants

type Day = variant {
Sun;
Mon;
Tue;
Wed;
Thu;
Fri;
Sat;
}

[query]
fn get_text(d: Day) -> &'static str {
match d {
Day::Sun => "Sunday",
Day::Mon => "Monday",
Day::Tue => "Tuesday",
Day::Wed => "Wednesday",
Day::Thu => "Thursday",
Day::Fri => "Friday",
Day::Sat => "Saturday",
}
}