lib-nested/math/int2str/src/main.rs

37 lines
683 B
Rust
Raw Normal View History

2021-11-19 12:19:52 +01:00
use std::{fs::File, io::Read, os::unix::io::FromRawFd};
2021-04-19 05:02:46 +02:00
fn main() {
nested::magic_header();
eprintln!(" Human-readably Print MachineInt");
nested::magic_header();
let mut f0 = unsafe { File::from_raw_fd(0) };
2021-11-19 12:19:52 +01:00
eprintln!(
"
2021-05-03 19:55:29 +02:00
>0:
2021-04-19 05:02:46 +02:00
( )
( MachineInt )
( MachineWord )
2021-05-03 19:55:29 +02:00
( Stream MachineSyllab )
2021-11-19 12:19:52 +01:00
"
);
2021-04-19 05:02:46 +02:00
2021-11-19 12:19:52 +01:00
eprintln!(
"
2021-05-03 19:55:29 +02:00
<1:
2021-04-19 05:02:46 +02:00
( )
2021-05-03 19:55:29 +02:00
( PositionalInt 10 BigEndian )
( Sequence ( Digit 10 ) )
( Sequence UTF-8-Char )
( Stream UTF-8-Char )
( Stream MachineSyllab )
2021-11-19 12:19:52 +01:00
"
);
2021-04-19 05:02:46 +02:00
nested::magic_header();
let mut bytes = [0 as u8; 8];
2021-05-13 16:22:30 +02:00
f0.read_exact(&mut bytes).expect("");
2021-04-19 05:02:46 +02:00
println!("{}", u64::from_le_bytes(bytes));
}