본문 바로가기

분류 전체보기293

[Rust] Derive 예제 (54일차) // 'Centimeters', a tuple struct that can be compared #[derive(PartialEq, PartialOrd)] struct Centimeters(f64); // 'Inches', a tuple struct that can be printed #[derive(Debug)] struct Inches(i32); impl Inches { fn to_centimeters(&self) -> Centimeters { let &Inches(inches) = self; Centimeters(inches as f64 * 2.54) } } // 'Seconds', a tuple struct with no additional attributes struct Seconds(i32);.. 2023. 2. 7.
[JavaScript] Input에 null 값 막기 script에 click event function으로 들어오는 값을 검수하여 null이면 알림을 띄운다 input 자체에서 null 값을 못 넣게 한다 -> required 넣기 ==> required 만 넣으면 Browser에서 알아서, text 넣으라고 알림을 띄운다! https://ninetynine-2026.tistory.com/320 2023. 2. 5.
[Rust] Tokio 예제 : 기본 (53일차) use tokio::net::TcpListener; use tokio::io::{AsyncReadExt, AsyncWriteExt}; #[tokio::main] async fn main() -> Result { let listener = TcpListener::bind("127.0.0.1:8080").await?; loop { let (mut socket, _) = listener.accept().await?; tokio::spawn(async move { let mut buf = [0; 1024]; // In a loop, read data from the socket and write the data back. loop { let n = match socket.read(&mut buf).await {.. 2023. 2. 5.
[Rust] HashMap 예제 (52일차) fn main() { use std::collections::HashMap; // HashMap 생성 let mut hash_ages : HashMap = HashMap::new(); // 데이터 삽입 hash_ages.insert(String::from("Nachfolge"), 32); println!("HashMap : {:?}", hash_ages); } fn main() { use std::collections::HashMap; // HashMap 키에 해당하는 벡터 생성 let names = vec![String::from("Nachfolge"), String::from("Selah")]; // HashMap 값에 해당하는 벡터 생성 let ages = vec![10, 50]; // HashMa.. 2023. 2. 3.