test: add real-world and comprehensive example files

This commit is contained in:
2026-03-27 10:35:04 +01:00
parent 0e54fc38a2
commit f63db82586
2 changed files with 117 additions and 0 deletions
+87
View File
@@ -0,0 +1,87 @@
use std::collections;
struct Point { x, y }
struct Wrapper(inner);
enum Shape {
Circle(radius),
Rectangle { width, height },
Unknown,
}
pub fn describe(shape) {
match shape {
Shape::Circle(r) => `circle with radius ${r}`,
Shape::Rectangle { width, height } => {
let area = width * height;
`rectangle with area ${area}`
},
_ => "unknown shape",
}
}
pub async fn fetch_data(url) {
let response = http::get(url).await;
response
}
fn fibonacci() {
let a = 0;
let b = 1;
loop {
yield a;
let c = a + b;
a = b;
b = c;
}
}
pub fn make_counter() {
let count = 0;
let increment = || {
count = count + 1;
count
};
increment
}
fn check_type(value) {
if value is String {
println!("it's a string");
}
if value is not Vec {
println!("not a vector");
}
}
fn objects() {
let config = #{
name: "test",
debug: true,
count: 42,
};
}
async fn race_futures(a, b) {
select {
result = a => result,
result = b => result,
}
}
pub fn refresh() {
let items = [];
items.push(Item::new("id", "name", "cmd")
.description("A description")
.icon("icon-name")
.keywords(["one", "two"]));
items
}
pub fn query(q) {
[]
}
+30
View File
@@ -0,0 +1,30 @@
use owlry::Item;
pub fn refresh() {
let items = [];
items.push(Item::new("hs-logout", "logout", "hyprshutdown")
.description("Gracefully close all apps and exit Hyprland")
.icon("system-log-out")
.keywords(["logout", "exit", "quit", "signout", "logoff"]));
items.push(Item::new("hs-reboot", "reboot",
"hyprshutdown -t \"Restarting...\" --post-cmd \"systemctl reboot\"")
.description("Gracefully close all apps and reboot")
.icon("system-reboot")
.keywords(["reboot", "restart", "reset"]));
items.push(Item::new("hs-poweroff", "poweroff",
"hyprshutdown -t \"Powering off...\" --post-cmd \"systemctl poweroff\"")
.description("Gracefully close all apps and power off")
.icon("system-shutdown")
.keywords(["poweroff", "shutdown", "halt", "off"]));
items.push(Item::new("hs-firmware", "reboot-firmware",
"hyprshutdown -t \"Restarting to firmware...\" --post-cmd \"systemctl reboot --firmware-setup\"")
.description("Gracefully close all apps and reboot to UEFI/BIOS")
.icon("computer")
.keywords(["firmware", "bios", "uefi", "setup"]));
items
}