본문 바로가기

분류 전체보기293

[Rust] Overloading 예제 (51일차) use std::ops; struct Foo; struct Bar; #[derive(Debug)] struct FooBar; #[derive(Debug)] struct BarFoo; // The 'std::ops::Add' trait is used to specify the functionality of '+'. // Here, we make 'Add' - the trait for addition with a RHS of type 'Bar'. // The follow block implements the operation: Foo + bar = FooBar impl ops::Add for Foo { type Output = FooBar; fn add(self, _rhs: Bar) -> FooBar { p.. 2023. 2. 2.
[Rust] Field Init Shorthand, 필드 초기화 (50일차) Field Init Shorthand : 필드 초기화 단축 을 쓰는 이유? >> name field를가진 Data Structure (struct, enum, union)를 초기화할 때 fieldname: fieldname 형식으로 fieldname 작성을 압축 시켜 Code 중복을 적게하고 압축된 Syntax를 제공, >> When initializing a data structure (struct, enum, union) with named fields, allow writing fieldname as a shorthand for fieldname: fieldname. This allows a compact syntax for initialization, with less duplication. #[.. 2023. 2. 1.
[Rust] Web Server : Multi-Threading 추가 (49일차) >> 이전에 작업한 lib.rs 파일 Code 를 수정 >> 중간에 lifetime syntax ` 로 인해 주석처럼 보이나, 정상 Compile 되는 코드다. use std::thread; use std::sync::mpsc; use std::sync::Arc; use std::sync::Mutex; pub struct ThreadPool { workers: Vec, sender: mpsc::Sender, } trait FnBox { fn call_box(self: Box); } impl FnBox for F { fn call_box(self: Box) { (*self)() } } type Job = Box ThreadPool { assert!(size > 0); let (sender, receiver.. 2023. 1. 31.
[MySQL] Partition 예제 ==> PARTITION 할 때 Column 하나에만 Primary Key 를 걸면 Error 발생. ==> 모든 Column 을 Partition 해야함. CREATE TABLE sales ( sales_id INT, sales_date DATE, amount INT, PRIMARY KEY (sales_id, sales_date, amount) ) PARTITION BY RANGE(YEAR(sales_date)) ( PARTITION p_2015 VALUES LESS THAN (2016), PARTITION p_2016 VALUES LESS THAN (2017), PARTITION p_2017 VALUES LESS THAN (2018), PARTITION p_others VALUES LESS THAN .. 2023. 1. 30.