// #![feature(const_generics)] // fn rev<const X: usize>(from: &[u8; X], to: &mut [u8; X]) { // if from.len() > 0 {} // } #![feature(lang_items)] #![no_std] #![no_main] // use panic_abort; // use libc; fn rev(from: &[u8], to: &mut [u8]) { let len = from.len(); if len > 0 { rev(&from[1..], &mut to[..len - 1]); to[len - 1] = from[0]; } } const FROM: &[u8] = b"Hello Word!"; const SIZE: usize = FROM.len(); #[no_mangle] pub extern "C" fn main() { let mut to: [u8; SIZE] = [0; SIZE]; rev(&FROM[..], &mut to); unsafe { core::ptr::read_volatile(&to); } // println!("from : {:?}", std::str::from_utf8(FROM).unwrap()); // println!("to : {:?}", std::str::from_utf8(&to).unwrap()); } #[panic_handler] fn my_panic(_info: &core::panic::PanicInfo) -> ! { loop {} } // The reset vector, a pointer into the reset handler #[link_section = ".init"] #[no_mangle] pub extern "C" fn _start() -> ! { main(); loop {} } #[lang = "eh_personality"] extern "C" fn eh_personality() {} // #[lang = "panic_fmt"] // extern "C" fn panic_fmt() -> ! { // loop {} // }