Eyra Does the Impossible
blog.sunfishcode.online3 pointsby higherhalf1 comments
//usr/bin/env rustc "$0" && ./config "$@"; exit
Or //usr/bin/env rustc --edition 2024 "$0" && ./$(basename $0 .rs); rm $(basename $0 .rs); exit #![feature(import_trait_associated_functions)]
use std::iter::Iterator::{filter, map, collect};
fn get_ids2(data: Vec<Widget>) -> Vec<Id> {
collect(map(filter(Vec::into_iter(data), |w| w.alive), |w| w.id))
}
fn get_ids3(data: impl Iterator<Item = Widget>) -> Vec<Id> {
collect(map(filter(data, |w| w.alive), |w| w.id))
} global _start
_start:
jmp next
string:
db `Hello World!\n`
len: equ $ - string
next:
mov ecx, string
mov edx, len
mov ebx, 1
mov eax, 4
int 80h
mov ebx, 0
mov eax, 1
int 80h
For NASM, it can also be put into a macro, for example printing to video memory at 0xb8000: %macro print 1
mov ecx, %%loop_start - %%strdata
mov eax, 0x0700
jmp %%loop_start
%%strdata: db %1
%%loop_start:
mov al, [%%strdata + ecx - 1]
mov [0xb8000 + ecx * 2 - 2], ax
loop %%loop_start
%endmacro