코딩Coding/Rust연습
-
Rust Machine learning code 불완전함코딩Coding/Rust연습 2022. 8. 13. 23:52
https://github.com/maciejkula/rustlearn GitHub - maciejkula/rustlearn: Machine learning crate for Rust Machine learning crate for Rust. Contribute to maciejkula/rustlearn development by creating an account on GitHub. github.com https://rustrepo.com/repo/maciejkula-rustlearn-rust-machine-learning Machine learning crate for Rust | RustRepo rustlearn A machine learning package for Rust. For full us..
-
Rust연습❤️“rust spinning rod animation in text” Code Answer코딩Coding/Rust연습 2022. 8. 13. 23:43
fn main() { let characters = ['|', '/', '-', '\\']; let mut current = 0; println!("{}[2J", 27 as char); // Clear screen. loop { println!("{}[;H{}", 27 as char, characters[current]); // Move cursor to 1,1 and output the next character. current += 1; // Advance current character. if current == 4 { current = 0; } // If we reached the end of the array, start from the beginning. std::thread::sleep(st..
-
Rust연습❤️Processing 0~100%올라가는 프린트 ㅎㅎ코딩Coding/Rust연습 2022. 8. 13. 23:23
use std::{ io::{stdout, Write}, thread::sleep, time::Duration, }; fn main() { let mut stdout = stdout(); for i in 0..=100 { print!("\rProcessing {}%...", i); // or // stdout.write(format!("\rProcessing {}%...", i).as_bytes()).unwrap(); stdout.flush().unwrap(); sleep(Duration::from_millis(20)); } println!(); } cargo run Compiling char v0.1.0 (/Users/globalyoung/Documents/test/rust/char) Finished ..
-
Rust연습❤️HashMap, Arc, Mutex, thread연습코딩Coding/Rust연습 2022. 8. 13. 18:51
main.rs // Thanks: https://stackoverflow.com/a/53894298/665869 use std::collections::HashMap; use std::sync::{Arc, Mutex}; use std::thread; type Map = HashMap; fn handle_n_times(count: i32, arc_map: Arc) { for i in 0..count { let clone_arc = arc_map.clone(); thread::spawn(move || { let mut map = clone_arc.lock().unwrap(); map.insert(format!("key-{}", i), format!("value-{}", i)); }); } } fn print..
-
Rust연습❤️] Hello from asm__assembly코드 연습코딩Coding/Rust연습 2022. 7. 3. 00:41
Rust Playground에서는 잘 실행 된다. 인텔 cpu칩인가 보다 ㅠㅠ You can try this example on the playground Rust Playground play.rust-lang.org .) use std::arch::asm; #[feature(asm)] fn main() { let buf = "Hello from asm!\n"; let ret: i32; unsafe { asm!( "syscall", in("rax") 1, // syscall number in("rdi") 1, // fd in("rsi") buf.as_ptr(), in("rdx") buf.len(), out("rcx") _, // clobbered by syscalls out("r11") _, // clo..
-
Rust연습❤️] Displaying raw pointers코딩Coding/Rust연습 2022. 7. 3. 00:38
결과 // https://riptutorial.com/rust/example/24222/displaying-raw-pointers use std::ptr; // Create some data, a raw pointer pointing to it and a null pointer fn main() { let data: u32 = 42; let raw_ptr = &data as *const u32; let null_ptr = ptr::null() as *const u32; // the {:p} mapping shows pointer values as hexadecimal memory addresses println!("Data address: {:p}", &data); println!("Raw pointer..
-
Rust연습❤️내 컴퓨터에 병렬 실행 가능한 코어수 알아보기available_parallelism코딩Coding/Rust연습 2022. 6. 29. 00:33
Rust 내 컴퓨터에 병렬 실행 가능한 코어수 알아보기 fn main () { println!("You can use {:?} threads(available_parallelism) now. ", std::thread::available_parallelism().unwrap()); } 결과 Compiling playground v0.0.1 (/playground) Finished dev [unoptimized + debuginfo] target(s) in 0.75s Running `target/debug/playground` Standard Output You can use 2 threads(available_parallelism) now. 다른 글 보기 C언어] ❤️ OpenMP를 사용해서 내 컴퓨터의..