All posts for tag "rust"

Total 4 posts
📄 Rust Pass Input to Command Stdin
C:2023-06-26 M:2023-06-26
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 use std::{process::{Command, Stdio}, io::Write}; fn copy_to_clipboard_wcopy(s: String) { let mut wcopy = Command::new("wc") .arg("-c") .stdin(Stdio::piped()) .stdout(Stdio::piped()) .spawn() .expect("Failed to spawn `xclip`: please ensure you have it installed."); let mut stdin = wcopy.stdin.take().expect("Failed to write to stdin"); std::thread::spawn(move || { stdin.write_all(s.as_bytes()).expect("Failed to write to stdin"); }); let output = wcopy.
📄 Rust Import Module
C:2023-03-07 M:2023-03-07
Suppose we have two files src/main.rs and src/utils.rs, to use utils.rs in main.rs, there are two ways that work. Use mod keyword in main.rs 1 2 3 / main.rs mod crate::utils; / mod utils; / use relative path to import Use pub mod keyword in lib.rs create a lib.rs file in src directory. 1 2 / lib.rs pub mod utils; then add this in main.rs 1 use <packageName>::utils;
📄 Rust_libraries
C:2023-03-01 M:2023-03-01
Resources awesome-rust 日常开发第三方库精选 Rust Language Related Error crate description anyhow Flexible concrete Error type built on std::error::Error thiserror derive(Error) futures futures and streams featuring zero allocations, composability, and iterator-like interfaces Logging crate description log Offical, to show message, it needs a implementation, recommend env_logger tracing trace, better for async programming development Concurrency crate description tokio suitable for IO-intensive computing, not the
📄 rCore
C:2023-02-20 M:2023-02-20
Based on rCore-Tutorial-Guide 2023 春季学期 and rCore-Tutorial-Book 第三版 Useful Command To show platforms based on RISC-V that rustc supports 1 rustc –print target-list | grep riscv Rust Note Cross Build (RISC-V) .cargo/.config [build] target = "riscv64gc-unknown-none-elf" No Std Besides remove std section, you can refer to smallest no std - The Embedonomicon. Notes Linker Script linker script specifications: info ld Scripts or you can read