본문 바로가기

예제15

[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.
[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.
[Rust] Thunk 예제 (47일차) fn main() { // Define and call a thunk let thunk = || println!("I am a thunk"); thunk(); // Defining a closure and storing it in a variable to be used later let closure = || { println!("This is a closure stored in a variable"); }; closure(); } fn main() { // Pass a thunk as an argument to a function fn call_thunk(thunk: &dyn Fn()) { thunk(); } let thunk = || println!("I am a thunk"); call_thunk(.. 2023. 1. 29.
[MySQL] With 예제 WITH RECURSIVE cte (n, fibonacci) AS ( SELECT 1, 1 UNION ALL SELECT n + 1, fibonacci + cte.fibonacci FROM cte WHERE n with를 통해 조건_1로 필터링 한 data를 조건_2로 다시 필터링 WITH cte AS ( SELECT * FROM table_1 WHERE condition_1 ) SELECT * FROM cte WHERE condition_2; https://chat.openai.com/chat 2023. 1. 29.