일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
- rust
- 리뷰
- dcgan
- keras
- 지진
- kaggle
- Ai
- Rocket
- Attention
- MNIST
- C++
- 지진봇
- 책
- CNN
- Kotlin
- GAN
- TensorFlow
- cpp
- RNN
- wasm
- 인공지능
- js
- Music
- VRChat
- Python
- Web
- WPF
- 케모노 프렌즈
- c#
- Today
- 57
- Total
- 155,811
목록rust (46)
NeuroWhAI의 잡블로그
출처 : https://rust-lang.github.io/api-guidelines/future-proofing.html C++이나 C#에 보면 sealed라는 키워드가 있습니다. 이걸로 수식된 클래스는 상속의 끝을 뜻하며 자식 클래스를 가질 수 없죠. 보통 다른 개발자가 의도치 않게 자신의 클래스를 상속하고 확장하는 것을 방지하기 위한 용도로 쓰입니다. Rust에서도 이와 비슷한 목적으로 trait을 sealed 시킬 수 있습니다. 다만 키워드로 지원하는 것은 아니고 문법을 이용합니다. 다른 개발자가 trait을 사용할 수는 있어도 다른 타입에 impl하는 것은 막는 것이죠. pub trait Foo: private::Sealed { fn foo(&self); } impl Foo for usize {..

Rust 컴파일러는 기본적으로 모든 타입을 이동 가능한 것으로 취급합니다. 실제로 대부분의 타입은 이동되어도 문제가 없죠. 그러나 세상 사는 게 그렇게 순탄하지는 않습니다. 만약 i32 변수 a와 이를 가리키는 포인터 b가 있고 둘 다 객체 obj의 멤버라고 합시다. obj { a
https://rust-lang.github.io/async-book/02_execution/01_chapter.html Under the Hood: Executing Futures and Tasks - Asynchronous Programming in Rust In this section, we'll cover the underlying structure of how Futures and asynchronous tasks are scheduled. If you're only interested in learning how to write higher-level code that uses existing Future types and aren't interested in the details of how..

그냥 C++로 된 튜토리얼 보고 Rust로 옮겨 적은 것 뿐... 이해해보려고 하긴 했는데 아무래도 수학적인 부분은 영;; https://github.com/NeuroWhAI/tinyraytracer-rs NeuroWhAI/tinyraytracer-rs tinyraytracer in rust. Contribute to NeuroWhAI/tinyraytracer-rs development by creating an account on GitHub. github.com
Rust 표준 라이브러리에 있는 AsRef와 Borrow trait은 생긴 것이 매우 비슷합니다. pub trait AsRef where T: ?Sized, { fn as_ref(&self) -> &T; } pub trait Borrow where Borrowed: ?Sized, { fn borrow(&self) -> &Borrowed; } impl Borrow for T impl
주의! 공부하고 정리한 글이라서 틀린 부분이 있을 수 있습니다.올바른 지적은 언제나 환영합니다. Rust는 패턴 매칭시 적절한 바인딩 모드를 선택함으로써 프로그래머 입장에서 쉽게 패턴 매칭 코드를 작성할 수 있게 합니다.다만 구버전 Rust까지는 그런 기능이 부족해서 아래 코드는 컴파일이 안되었었습니다. let s: &Option = &Some("hello".to_string()); match s { Some(s) => println!("s is: {}", s), _ => (), };s는 &Option인데 패턴은 Option이기 때문이었죠.그래서 아래처럼 수정해야 했었습니다. let s: &Option = &Some("hello".to_string()); match s { &Some(ref s) => p..
use std::io::{self, Read}; mod bf { use std::io::{self, Read}; #[derive(Default)] pub struct Machine { code: Vec, ram: Vec, head: usize, ptr: usize, } impl Machine { pub fn new() -> Self { Machine::default() } } impl Machine { pub fn initialize(&mut self, ram_size: usize) { self.ram.resize(ram_size, 0); } pub fn mount(&mut self, code: &str) { self.code = code.chars().collect(); } pub fn step(&mu..
panic은 Rust의 매크로로서 프로그램이 복구할 수 없는 오류에 빠졌을 때 프로그램을 즉시 종료하고 디버깅에 필요한 정보를 제공하는 기능을 합니다.Rust는 panic이 일어난 것을 감지할 수 있는 기능도 제공합니다. use std::panic; fn main() { let result = panic::catch_unwind(|| -> i32 { println!("good"); "42".parse().unwrap() }); println!("{:?}", result); let result = panic::catch_unwind(|| -> i32 { println!("bad"); "AaaaaAAaaaAAAaaAAAAaAAAAA".parse().unwrap() }); println!("{:?}", res..
if self.cache.contains_key(ids) { let sub_cache = self.cache.get_mut(ids).unwrap(); if sub_cache.contains_key(page_id) { let data = sub_cache.get_mut(page_id).unwrap(); data.update(cnt); } else { // 캐시가 비정상적으로 커질 가능성 배제. if sub_cache.len() >= self.max_sub_cache_len { sub_cache.clear(); } sub_cache.insert(page_id.clone(), CacheData::new(cnt)); } } else { let mut sub_cache = HashMap::new(); sub_ca..
https://turbo.fish/ 터보피쉬는 물고기의 한 종류 Rust의 문법 중 하나입니다.C++로 따지면 템플릿 파라미터를 직접 지정하는 것과 비슷하다고 할 수 있습니다. let num = "42".parse();위 코드는 컴파일이 안됩니다.타입 추론에 필요한 정보가 부족하기 때문이죠.num의 타입을 추론하자니 parse의 반환형이 제너릭 타입이라 알 수 없고parse의 제너릭 타입을 추론하자니 num의 타입을 모르는 상황이죠.두 해결 방법이 있는데 그냥 num: i32 이렇게 num의 타입을 지정하는 것과parse에 turbofish 문법을 사용해서 해결할 수도 있습니다. let num: i32 = "42".parse(); let num = "42".parse::(); // turbofish사실 ..