diff --git a/docs/01_ko.html b/docs/01_ko.html index 7855dd8710f8f542fcaf5ead53ed624af1d77eb9..3f239d44d914077e84f194262b2d81b9f1d954ce 100644 --- a/docs/01_ko.html +++ b/docs/01_ko.html @@ -85,7 +85,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/02_ko.html b/docs/02_ko.html index 8a6f1fc73ac13e53b3b3f90da681e9c8e69b28b6..931a23d50dfe38cf430d2dbf1de318c98393b44f 100644 --- a/docs/02_ko.html +++ b/docs/02_ko.html @@ -83,7 +83,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/03_ko.html b/docs/03_ko.html index 39c9dd9912f8fe586b27add183f2a467356ff28a..386418d1bd42af12713d7319194ce2a6f69e7955 100644 --- a/docs/03_ko.html +++ b/docs/03_ko.html @@ -80,7 +80,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/04_ko.html b/docs/04_ko.html index 6f3e9e44990d8aa7a8a78834ed71796dde48fdf4..de24baed493a08595e712a8bab039e55e20baf20 100644 --- a/docs/04_ko.html +++ b/docs/04_ko.html @@ -76,7 +76,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/05_ko.html b/docs/05_ko.html index e3545a65529b20d95a849ebcbd74834899678c63..ed9a4df04e764c72263c2593663f7d966eb08b7b 100644 --- a/docs/05_ko.html +++ b/docs/05_ko.html @@ -71,7 +71,7 @@ $ Hello, world! (stdout) </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/07_ko.html b/docs/07_ko.html index 65fae5f317ca598b82c0c2fbfb64f3ad679c0f07..23f2170af31003bdb90765f234c28c022e372e60 100644 --- a/docs/07_ko.html +++ b/docs/07_ko.html @@ -78,7 +78,7 @@ fn main() { </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/08_ko.html b/docs/08_ko.html index 90168edca578eadabc6ea344ab8cb3d58304b716..9a43fa80d9db0d79019b0f8f605adba763419c5a 100644 --- a/docs/08_ko.html +++ b/docs/08_ko.html @@ -69,7 +69,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/09_ko.html b/docs/09_ko.html index eb0c74626afb139c72c5e7202a53f278eb14d45e..12b3465d6d409e9d331295f5e0e15cf30b1be40c 100644 --- a/docs/09_ko.html +++ b/docs/09_ko.html @@ -66,7 +66,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/10_ko.html b/docs/10_ko.html index 738f897c19119beebb2862ac38333410b01d8afa..efc829b0dae119775d52fab7153561b965c9d658 100644 --- a/docs/10_ko.html +++ b/docs/10_ko.html @@ -79,7 +79,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/11_ko.html b/docs/11_ko.html index a52d9e18dc7196f2db98263350d956d86022fc7f..04a2f3d3305bc92d3a432a372cdefe18cc1d2f33 100644 --- a/docs/11_ko.html +++ b/docs/11_ko.html @@ -102,7 +102,7 @@ let my_number_string = my_number.to_string(); // "42"라는 String 타입으로 </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/12_ko.html b/docs/12_ko.html index fd043e9eb950be68c15c9fabea05cf4860c2cc79..e47e64e370dce15bd0a31c12a8567763c06e0d6c 100644 --- a/docs/12_ko.html +++ b/docs/12_ko.html @@ -64,7 +64,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/13_ko.html b/docs/13_ko.html index 426c5a72d788779517cf82727efa0faed71cc6ec..32448d6f93c30ab0d6931c727865233311c5bf42 100644 --- a/docs/13_ko.html +++ b/docs/13_ko.html @@ -64,7 +64,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/14_ko.html b/docs/14_ko.html index b947b2afc12cf6540e61bd1c952f28e7fea1dedb..0032ad688bda14b81347ddf7ca16b3aca4733255 100644 --- a/docs/14_ko.html +++ b/docs/14_ko.html @@ -66,7 +66,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/15_ko.html b/docs/15_ko.html index 8dac31b44f7ecda5f88d1e811b5d5281ef36d409..2d12157bae04c106bbea0b2ce5a5afffac006f2f 100644 --- a/docs/15_ko.html +++ b/docs/15_ko.html @@ -80,7 +80,7 @@ if __name__ == "__main__": </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/16_ko.html b/docs/16_ko.html index 55aa11bdb41b7de9bcab0d04eaca49465a52a917..56a08e56350f8f8b80bc2d4f7e5094827cb41074 100644 --- a/docs/16_ko.html +++ b/docs/16_ko.html @@ -64,7 +64,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/17_ko.html b/docs/17_ko.html index 392e96ad7042c4a8bcbddc7e0f3f3875b03ac369..dbdee5b0f3fadd4e0e47c170a8d1bb030de51dbf 100644 --- a/docs/17_ko.html +++ b/docs/17_ko.html @@ -91,7 +91,7 @@ fn main() { </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/18_ko.html b/docs/18_ko.html index 8a0b88a98a720349ce8ed4d9165663e369671f35..328f0cb28cddb00399cf988b1092566fa8a55ca1 100644 --- a/docs/18_ko.html +++ b/docs/18_ko.html @@ -168,7 +168,7 @@ fn main() { </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/19_ko.html b/docs/19_ko.html index 74e58287de10939c59ee0ca0a801059ae8343d2d..7bc05c4295b549f6388e1a58aae5088a1928c8d6 100644 --- a/docs/19_ko.html +++ b/docs/19_ko.html @@ -63,7 +63,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/20_ko.html b/docs/20_ko.html index 8d4cd7729d9c3c7e8d56d19d935fdfa614b82857..0b8c5f1cae378a3e4d87141a2694ecd4b1fcca59 100644 --- a/docs/20_ko.html +++ b/docs/20_ko.html @@ -94,7 +94,7 @@ Rust에서는 결과를 나타내기 위해 Result 열거형을 사용합니다. </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/21_ko.html b/docs/21_ko.html index 7a03b8a13c759e109a8cdffc3fe817be1bd0e1f9..b7dddb9d7b708bc40b6a50dfbadb36e725c2d0a3 100644 --- a/docs/21_ko.html +++ b/docs/21_ko.html @@ -45,6 +45,91 @@ <li><a href="https://doc.rust-lang.org/1.30.0/book/2018-edition/ch03-02-data-types.html" target="_blank" rel="noopener">Website: Rust Book 2018 - 기본 데이터 유형에 대한 자세한 설명</a></li> <li><a href="https://cheats.rs/#basic-types" target="_blank" rel="noopener">Website: Rust Cheat Sheet - Data Types</a></li> </ul> +<div> <button type="button" class="collapsible">정답 보기</button> <div class="content"> <pre><code class="rust">enum Shape { + Circle(f64), // 반지름 + Rectangle(f64, f64), // 가로, 세로 + Triangle(f64, f64, f64), // 세 변의 길이 +} + +// 넓이를 계산하는 함수 +fn area(shape: &Shape) -> f64 { + match shape { + Shape::Circle(r) => 3.14 * r * r, + Shape::Rectangle(w, h) => w * h, + Shape::Triangle(a, b, c) => { + // 삼각형의 넓이 공식 + let s = (a + b + c) / 2.0; + let area = s * (s - a) * (s - b) * (s - c); + // 넓이가 음수면 에러 발생 + if area < 0.0 { + panic!("Invalid triangle"); + } else { + area.sqrt() + } + } + } +} + +// 둘레를 계산하는 함수 +fn perimeter(shape: &Shape) -> f64 { + match shape { + Shape::Circle(r) => 2.0 * 3.14 * r, + Shape::Rectangle(w, h) => 2.0 * (w + h), + Shape::Triangle(a, b, c) => { + // 삼각형의 둘레 공식 + let p = a + b + c; + // 둘레가 음수면 에러 발생 + if p < 0.0 { + panic!("Invalid triangle"); + } else { + p + } + } + } +} + +// 정사각형인지 판별하는 함수 +fn is_square(shape: &Shape) -> bool { + match shape { + Shape::Circle(_) => false, + Shape::Rectangle(w, h) => w == h, + Shape::Triangle(_, _, _) => false, + } +} + +// 결과 +/* +원 넓이: 12.56 +사각형 넓이: 12 +삼각형 넓이: 6 +원 둘레: 12.56 +사각형 둘레: 14 +삼각형 둘레: 12 +원이 정사각형인가? false +사각형이 정사각형인가? false +삼각형이 정사각형인가? false +*/ +fn main() { + // Shape 타입의 값들을 생성합니다. + let circle = Shape::Circle(2.0); + let rectangle = Shape::Rectangle(3.0, 4.0); + let triangle = Shape::Triangle(3.0, 4.0, 5.0); + + // 각 도형의 넓이를 출력합니다. + println!("원 넓이: {}", area(&circle)); + println!("사각형 넓이: {}", area(&rectangle)); + println!("삼각형 넓이: {}", area(&triangle)); + + // 각 도형의 둘레를 출력합니다. + println!("원 둘레: {}", perimeter(&circle)); + println!("사각형 둘레: {}", perimeter(&rectangle)); + println!("삼각형 둘레: {}", perimeter(&triangle)); + + // 각 도형이 정사각형인지 출력합니다. + println!("원이 정사각형인가? {}", is_square(&circle)); + println!("사각형이 정사각형인가? {}", is_square(&rectangle)); + println!("삼각형이 정사각형인가? {}", is_square(&triangle)); +}</code></pre> </div> </div> <div class="bottomnav"> <span class="back"><a href="20_ko.html" rel="prev">❮ 이전</a></span> <span class="next"><a href="chapter_2_ko.html" rel="next">다음 ❯</a></span> @@ -69,7 +154,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/23_ko.html b/docs/23_ko.html index f97528d1e69c3b8ddecdb53888f34f511e62a478..63e86968eb307571c33483c9bcaf42a839cc587c 100644 --- a/docs/23_ko.html +++ b/docs/23_ko.html @@ -74,7 +74,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/24_ko.html b/docs/24_ko.html index 885f16dfcc5cb883cf9eb2aac4dafba192c3b93f..47242ece6aee8441b0693f944daa7fa8995c29bb 100644 --- a/docs/24_ko.html +++ b/docs/24_ko.html @@ -89,7 +89,7 @@ fn main() { </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/25_ko.html b/docs/25_ko.html index a589fc5f1a2e713fc0d60301bd07f2452d3f9700..108a1637b38a92bbd72aad73190ca7bbba837f13 100644 --- a/docs/25_ko.html +++ b/docs/25_ko.html @@ -59,7 +59,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/26_ko.html b/docs/26_ko.html index 2298821b4d362837ffcb48723260e98e4eef3746..730c51ae043da9b37a2d8e07545f350d0edd41d5 100644 --- a/docs/26_ko.html +++ b/docs/26_ko.html @@ -90,7 +90,7 @@ struct Person<'a> { </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/27_ko.html b/docs/27_ko.html index 7026597073ce7e5e4593d491ff063ede12b4247c..4388a138a8d91c32e5731c7af207f254ed35d396 100644 --- a/docs/27_ko.html +++ b/docs/27_ko.html @@ -78,7 +78,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/28_ko.html b/docs/28_ko.html index f852717674fa368ca7d1819b6b1ab63fe2e4b70c..2ea174a359f0489b73e4e3e46f08642d55cc00bb 100644 --- a/docs/28_ko.html +++ b/docs/28_ko.html @@ -59,7 +59,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/29_ko.html b/docs/29_ko.html index 2daee61c1e22bb27182b6a600dc8f585428388c4..d445ee217c9f12e4688f439fcc53001d3ad6c5dd 100644 --- a/docs/29_ko.html +++ b/docs/29_ko.html @@ -61,7 +61,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/31_ko.html b/docs/31_ko.html index d8c4b651b7fa3bfd20f0f30aedd756d6863e3a9a..399011fc63740bb8713d7663b14070a6242fa1cf 100644 --- a/docs/31_ko.html +++ b/docs/31_ko.html @@ -59,7 +59,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/33_ko.html b/docs/33_ko.html index c532c2463a3d29503b5fefb3ffd672dd235d1c5a..326f4db41fa4d2d47318f506892c7ddae7d44429 100644 --- a/docs/33_ko.html +++ b/docs/33_ko.html @@ -59,7 +59,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/34_ko.html b/docs/34_ko.html index df0b9921ac6f288d224e3c56813a737322faee04..22b361cbfb2eb95987b08b487ec0ae3cd123b326 100644 --- a/docs/34_ko.html +++ b/docs/34_ko.html @@ -61,7 +61,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/36_ko.html b/docs/36_ko.html index 46d06eb9bb1ffe0844dfedad16c64ec1f714a749..92162c6e6a2ea4e8c4d2fe1b833d92b61d67a4ca 100644 --- a/docs/36_ko.html +++ b/docs/36_ko.html @@ -59,7 +59,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/38_ko.html b/docs/38_ko.html index 57c0770bfb3cf3b2019a37f5d7a306fc09fdfcb4..f42220be22b0afbee8813d5dd5aa84fbc9423c11 100644 --- a/docs/38_ko.html +++ b/docs/38_ko.html @@ -59,7 +59,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/40_ko.html b/docs/40_ko.html index 7645387926e75a12605f532915f97e397dcf1f22..f0e69938a98b916ca6af80045f924b2b17bdcd9b 100644 --- a/docs/40_ko.html +++ b/docs/40_ko.html @@ -59,7 +59,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/chapter_1_ko.html b/docs/chapter_1_ko.html index 130957deac89e6556823647f453673448ef454b9..f47514918f2e10a4d3cf8c89e35f15a751cbb08a 100644 --- a/docs/chapter_1_ko.html +++ b/docs/chapter_1_ko.html @@ -63,7 +63,7 @@ println!("Hello, Rustacean!");</code></pre> </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/chapter_2_ko.html b/docs/chapter_2_ko.html index 6202d9a5a62c0e4687dc8cae1959839486ffb678..6b49839732034af0cd7f6f7d4e52d4104d5b4d6a 100644 --- a/docs/chapter_2_ko.html +++ b/docs/chapter_2_ko.html @@ -79,7 +79,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/chapter_3_ko.html b/docs/chapter_3_ko.html index 045cbe9946111d68649841e8b180664b3fd548cf..51001c36b1b6691685f4ee67fba0ce9d0f998e8d 100644 --- a/docs/chapter_3_ko.html +++ b/docs/chapter_3_ko.html @@ -59,7 +59,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/chapter_4_ko.html b/docs/chapter_4_ko.html index 9ea375e544dc9c88334f6d8ed72a97a831b6ead5..7f86b4e32d4f49a691e1003150fde7c6c1da9f13 100644 --- a/docs/chapter_4_ko.html +++ b/docs/chapter_4_ko.html @@ -59,7 +59,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/chapter_5_ko.html b/docs/chapter_5_ko.html index 2448281a890d52eaf051351f064be9079556fa9c..863a6e768bd9c5d7b97f6c7cc457db80c96fde9f 100644 --- a/docs/chapter_5_ko.html +++ b/docs/chapter_5_ko.html @@ -60,7 +60,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/chapter_6_ko.html b/docs/chapter_6_ko.html index be1afa87aea15405ac61e897528bb86251de52e8..a1528f08cd82d64bc5cb9feaeac132f0187bd7c6 100644 --- a/docs/chapter_6_ko.html +++ b/docs/chapter_6_ko.html @@ -60,7 +60,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/chapter_7_ko.html b/docs/chapter_7_ko.html index de9091930e6fcf6c425e1d33a45ddfc31721bdf5..415bcc2bf9498a29f23bc2f01cad062e0d352f52 100644 --- a/docs/chapter_7_ko.html +++ b/docs/chapter_7_ko.html @@ -61,7 +61,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/highlight.badge.js b/docs/highlight.badge.js index 566adf2fd866fdc23bfe53c4819d9895edde93d1..5f96816fc00985ec4c54c300776de51964897b89 100644 --- a/docs/highlight.badge.js +++ b/docs/highlight.badge.js @@ -238,7 +238,7 @@ Uses some ES6 features so won't work in IE without shims: var text = $code.textContent || $code.innerText; if (options.blogURL) { - text = text + "\n\n" + `[ 출처: ${options.blogURL} ]`; + text = text + "\n\n" + `// [ source: ${options.blogURL} ]`; } // Create a textblock and assign the text and add to document diff --git a/docs/highlight.badge.min.js b/docs/highlight.badge.min.js index cac5fea1be4646d849336862d3b06d68c9e8a4f1..97ee4e7fd5ca6a10f601ff3448c159a866737b8b 100644 --- a/docs/highlight.badge.min.js +++ b/docs/highlight.badge.min.js @@ -1 +1,185 @@ -"use strict";!function(e,o){"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?o(e,!0):function(e){if(!e.document)throw Error("A window with a document is required");return o(e)}:o(e)}("undefined"!=typeof window?window:this,function(e,o){if("boolean"!=typeof t)var t=!1;function n(o){var t,n={templateSelector:"#CodeBadgeTemplate",contentSelector:"body",loadDelay:0,copyIconClass:"far fa-clipboard",copyIconContent:"",checkIconClass:"fa fa-check text-success",checkIconContent:"",blogURL:""};function c(){n.loadDelay?setTimeout(a,loadDelay):a()}function a(){if(!document.querySelector(n.templateSelector)){var o=document.createElement("div");o.innerHTML=function e(){for(var o=["<style>","@media print {"," .code-badge { display: none; }","}"," .code-badge-pre {"," position: relative;"," }"," .code-badge {"," display: flex;"," flex-direction: row;"," white-space: normal;"," background: transparent;"," background: #333;"," color: white;"," font-size: 0.875em;"," opacity: 0.5;"," transition: opacity linear 0.5s;"," border-radius: 0 0 0 7px;"," padding: 5px 8px 5px 8px;"," position: absolute;"," right: 0;"," top: 0;"," }"," .code-badge.active {"," opacity: 0.8;"," }",""," .code-badge:hover {"," opacity: .95;"," }",""," .code-badge a,"," .code-badge a:hover {"," text-decoration: none;"," }",""," .code-badge-language {"," margin-right: 10px;"," font-weight: 600;"," color: goldenrod;"," }"," .code-badge-copy-icon {"," font-size: 1.2em;"," cursor: pointer;"," padding: 0 7px;"," margin-top:2;"," }"," .fa.text-success:{ color: limegreen !important }","</style>",'<div id="CodeBadgeTemplate" style="display:none">',' <div class="code-badge">',' <div class="code-badge-language" >{{language}}</div>',' <div title="Copy to clipboard">',' <i class="{{copyIconClass}} code-badge-copy-icon"></i></i></a>'," </div>"," </div>","</div>",],t="",n=0;n<o.length;n++)t+=o[n]+"\n";return t}();var t=o.querySelector("style"),c=o.querySelector(n.templateSelector);document.body.appendChild(t),document.body.appendChild(c)}for(var a=document.querySelector(n.templateSelector).innerHTML,r=document.querySelectorAll("pre>code.hljs"),l=0;l<r.length;l++){var i=r[l];if(!i.querySelector(".code-badge")){var d=i.classList[0];"hljs"===d&&(d=i.classList[1].replace("language-","")),"ps"==(d=d?d.toLowerCase():"Rust")?d="powershell":"cs"==d?d="csharp":"js"==d?d="javascript":"ts"==d?d="typescript":"fox"==d&&(d="foxpro");var s=a.replace("{{language}}",d).replace("{{copyIconClass}}",n.copyIconClass).trim(),p=document.createElement("div");p.innerHTML=s,p=p.querySelector(".code-badge");var g=i.parentElement;g.classList.add("code-badge-pre"),n.copyIconContent&&(p.querySelector(".code-badge-copy-icon").innerText=n.copyIconContent),g.insertBefore(p,i)}}document.querySelector(n.contentSelector).addEventListener("click",function(o){var t,c,a,r,l;return o.srcElement.classList.contains("code-badge-copy-icon")&&(o.preventDefault(),o.cancelBubble=!0,r=(a=(c=(t=o).srcElement.parentElement.parentElement.parentElement).querySelector("pre>code")).textContent||a.innerText,n.blogURL&&(r=r+"\n\n"+`[ 출처: ${n.blogURL} ]`),(l=document.createElement("textarea")).value=r.trim(),document.body.appendChild(l),l.style.display="block",e.document.documentMode?l.setSelectionRange(0,l.value.length):l.select(),document.execCommand("copy"),document.body.removeChild(l),function e(o){var t=n.copyIconClass.split(" "),c=n.checkIconClass.split(" "),a=o.querySelector(".code-badge-copy-icon");a.innerText=n.checkIconContent;for(var r=0;r<t.length;r++)a.classList.remove(t[r]);for(var r=0;r<c.length;r++)a.classList.add(c[r]);setTimeout(function(){a.innerText=n.copyIconContent;for(var e=0;e<c.length;e++)a.classList.remove(c[e]);for(var e=0;e<t.length;e++)a.classList.add(t[e])},2e3)}(c)),!1})}Object.assign(n,t=o),"loading"==document.readyState?document.addEventListener("DOMContentLoaded",c):c()}e.highlightJsBadge=n,e.module&&e.module.exports&&(e.module.exports.highlightJsBadge=n),t&&n()}); \ No newline at end of file +"use strict"; +!(function (e, o) { + "object" == typeof module && "object" == typeof module.exports + ? (module.exports = e.document + ? o(e, !0) + : function (e) { + if (!e.document) + throw Error("A window with a document is required"); + return o(e); + }) + : o(e); +})("undefined" != typeof window ? window : this, function (e, o) { + if ("boolean" != typeof t) var t = !1; + function n(o) { + var t, + n = { + templateSelector: "#CodeBadgeTemplate", + contentSelector: "body", + loadDelay: 0, + copyIconClass: "far fa-clipboard", + copyIconContent: "", + checkIconClass: "fa fa-check text-success", + checkIconContent: "", + blogURL: "", + }; + function c() { + n.loadDelay ? setTimeout(a, loadDelay) : a(); + } + function a() { + if (!document.querySelector(n.templateSelector)) { + var o = document.createElement("div"); + o.innerHTML = (function e() { + for ( + var o = [ + "<style>", + "@media print {", + " .code-badge { display: none; }", + "}", + " .code-badge-pre {", + " position: relative;", + " }", + " .code-badge {", + " display: flex;", + " flex-direction: row;", + " white-space: normal;", + " background: transparent;", + " background: #333;", + " color: white;", + " font-size: 0.875em;", + " opacity: 0.5;", + " transition: opacity linear 0.5s;", + " border-radius: 0 0 0 7px;", + " padding: 5px 8px 5px 8px;", + " position: absolute;", + " right: 0;", + " top: 0;", + " }", + " .code-badge.active {", + " opacity: 0.8;", + " }", + "", + " .code-badge:hover {", + " opacity: .95;", + " }", + "", + " .code-badge a,", + " .code-badge a:hover {", + " text-decoration: none;", + " }", + "", + " .code-badge-language {", + " margin-right: 10px;", + " font-weight: 600;", + " color: goldenrod;", + " }", + " .code-badge-copy-icon {", + " font-size: 1.2em;", + " cursor: pointer;", + " padding: 0 7px;", + " margin-top:2;", + " }", + " .fa.text-success:{ color: limegreen !important }", + "</style>", + '<div id="CodeBadgeTemplate" style="display:none">', + ' <div class="code-badge">', + ' <div class="code-badge-language" >{{language}}</div>', + ' <div title="Copy to clipboard">', + ' <i class="{{copyIconClass}} code-badge-copy-icon"></i></i></a>', + " </div>", + " </div>", + "</div>", + ], + t = "", + n = 0; + n < o.length; + n++ + ) + t += o[n] + "\n"; + return t; + })(); + var t = o.querySelector("style"), + c = o.querySelector(n.templateSelector); + document.body.appendChild(t), document.body.appendChild(c); + } + for ( + var a = document.querySelector(n.templateSelector).innerHTML, + r = document.querySelectorAll("pre>code.hljs"), + l = 0; + l < r.length; + l++ + ) { + var i = r[l]; + if (!i.querySelector(".code-badge")) { + var d = i.classList[0]; + "hljs" === d && (d = i.classList[1].replace("language-", "")), + "ps" == (d = d ? d.toLowerCase() : "Rust") + ? (d = "powershell") + : "cs" == d + ? (d = "csharp") + : "js" == d + ? (d = "javascript") + : "ts" == d + ? (d = "typescript") + : "fox" == d && (d = "foxpro"); + var s = a + .replace("{{language}}", d) + .replace("{{copyIconClass}}", n.copyIconClass) + .trim(), + p = document.createElement("div"); + (p.innerHTML = s), (p = p.querySelector(".code-badge")); + var g = i.parentElement; + g.classList.add("code-badge-pre"), + n.copyIconContent && + (p.querySelector(".code-badge-copy-icon").innerText = + n.copyIconContent), + g.insertBefore(p, i); + } + } + document + .querySelector(n.contentSelector) + .addEventListener("click", function (o) { + var t, c, a, r, l; + return ( + o.srcElement.classList.contains("code-badge-copy-icon") && + (o.preventDefault(), + (o.cancelBubble = !0), + (r = + (a = (c = (t = o).srcElement.parentElement.parentElement + .parentElement).querySelector("pre>code")).textContent || + a.innerText), + n.blogURL && (r = r + "\n\n" + `// [ source: ${n.blogURL} ]`), + ((l = document.createElement("textarea")).value = r.trim()), + document.body.appendChild(l), + (l.style.display = "block"), + e.document.documentMode + ? l.setSelectionRange(0, l.value.length) + : l.select(), + document.execCommand("copy"), + document.body.removeChild(l), + (function e(o) { + var t = n.copyIconClass.split(" "), + c = n.checkIconClass.split(" "), + a = o.querySelector(".code-badge-copy-icon"); + a.innerText = n.checkIconContent; + for (var r = 0; r < t.length; r++) a.classList.remove(t[r]); + for (var r = 0; r < c.length; r++) a.classList.add(c[r]); + setTimeout(function () { + a.innerText = n.copyIconContent; + for (var e = 0; e < c.length; e++) a.classList.remove(c[e]); + for (var e = 0; e < t.length; e++) a.classList.add(t[e]); + }, 2e3); + })(c)), + !1 + ); + }); + } + Object.assign(n, (t = o)), + "loading" == document.readyState + ? document.addEventListener("DOMContentLoaded", c) + : c(); + } + (e.highlightJsBadge = n), + e.module && e.module.exports && (e.module.exports.highlightJsBadge = n), + t && n(); +}); diff --git a/docs/index.html b/docs/index.html index 71f55acb65cd8de14c3cc744a885d0d806bc0d14..464fee93e97dee6aac74de34ebdde2f46ce1fd2f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -83,7 +83,7 @@ </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html> \ No newline at end of file diff --git a/docs/tour.css b/docs/tour.css index 0079ae18385b495d01135b3e14787e0b42abdfe3..8f422d88aa3cf00bc7dbd326b56ea6018a96582f 100644 --- a/docs/tour.css +++ b/docs/tour.css @@ -495,3 +495,32 @@ h1 { .header:moz-full-screen { display: none; } + +/* Style the button that is used to open and close the collapsible content */ +.collapsible { + font-family: "Noto Sans KR", sans-serif; + background-color: #ff6801; + color: white; + cursor: pointer; + padding: 18px; + width: 100%; + border: none; + text-align: left; + outline: none; + font-size: 15px; +} + +/* Add a background color to the button if it is clicked on (add the .active class with JS), and when you move the mouse over it (hover) */ +.active, +.collapsible:hover { + background-color: #ff8f44; +} + +/* Style the collapsible content. Note: hidden by default */ +.content { + /* padding: 0 18px; */ + background-color: white; + max-height: 0; + overflow: hidden; + transition: max-height 0.2s ease-out; +} diff --git a/docs/tour.js b/docs/tour.js index f1245ee4ec8a1a32c83f05f17c0488a2c7238b36..c650aadb0d9f9499bbdcabed0cc7e607b1aa75af 100644 --- a/docs/tour.js +++ b/docs/tour.js @@ -64,6 +64,24 @@ document.addEventListener("touchmove", handleTouchMove, false); setupKeys(); document.addEventListener("DOMContentLoaded", function () { + const coll = document.getElementsByClassName("collapsible"); + // console.log(coll); + if (coll) { + let i; + + for (i = 0; i < coll.length; i++) { + coll[i].addEventListener("click", function () { + this.classList.toggle("active"); + let content = this.nextElementSibling; + if (content.style.maxHeight) { + content.style.maxHeight = null; + } else { + content.style.maxHeight = content.scrollHeight + "px"; + } + }); + } + } + const iframeElement = document.querySelector("iframe"); if (iframeElement) { setupKeys(); diff --git a/frontend/generate.js b/frontend/generate.js index 7e9c1f5bc34c05bb51522bfe08e42227c697f62c..eef9fd5b3d5fa13e81933b7f6c4e44913a6a9d7d 100644 --- a/frontend/generate.js +++ b/frontend/generate.js @@ -224,7 +224,7 @@ function template( </script> <footer> - <p>아주대학교 Software Tool Time - Rust 튜토리얼 (Basic)</p> + <p><a target="_blank" rel="noopener" href="https://www.youtube.com/c/SoftwareToolTime">아주대학교 Software Tool Time</a> - Rust 튜토리얼 (Basic)</p> </footer> </body> </html>`; diff --git a/frontend/lessons/ko/chapter_1.yaml b/frontend/lessons/ko/chapter_1.yaml index 23d5ea94618c61ef66d8957a9509c8b4ab48160a..f9b111f1cb9ff47c5fd9405c4fbbceefd7c87618 100644 --- a/frontend/lessons/ko/chapter_1.yaml +++ b/frontend/lessons/ko/chapter_1.yaml @@ -707,3 +707,117 @@ * [Website: Rust Book 2018 - 기본 데이터 유형에 대한 자세한 설명](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch03-02-data-types.html) * [Website: Rust Cheat Sheet - Data Types](https://cheats.rs/#basic-types) + + <div> + <button type="button" class="collapsible">정답 보기</button> + <div class="content"> + %rust% + + enum Shape { + Circle(f64), // 반지름 + Rectangle(f64, f64), // 가로, 세로 + Triangle(f64, f64, f64), // 세 변의 길이 + } + + + // 넓이를 계산하는 함수 + + fn area(shape: &Shape) -> f64 { + match shape { + Shape::Circle(r) => 3.14 * r * r, + Shape::Rectangle(w, h) => w * h, + Shape::Triangle(a, b, c) => { + // 삼각형의 넓이 공식 + let s = (a + b + c) / 2.0; + let area = s * (s - a) * (s - b) * (s - c); + // 넓이가 음수면 에러 발생 + if area < 0.0 { + panic!("Invalid triangle"); + } else { + area.sqrt() + } + } + } + } + + + // 둘레를 계산하는 함수 + + fn perimeter(shape: &Shape) -> f64 { + match shape { + Shape::Circle(r) => 2.0 * 3.14 * r, + Shape::Rectangle(w, h) => 2.0 * (w + h), + Shape::Triangle(a, b, c) => { + // 삼각형의 둘레 공식 + let p = a + b + c; + // 둘레가 음수면 에러 발생 + if p < 0.0 { + panic!("Invalid triangle"); + } else { + p + } + } + } + } + + + // 정사각형인지 판별하는 함수 + + fn is_square(shape: &Shape) -> bool { + match shape { + Shape::Circle(_) => false, + Shape::Rectangle(w, h) => w == h, + Shape::Triangle(_, _, _) => false, + } + } + + + // 결과 + + /* + + 원 넓이: 12.56 + + 사각형 넓이: 12 + + 삼각형 넓이: 6 + + 원 둘레: 12.56 + + 사각형 둘레: 14 + + 삼각형 둘레: 12 + + 원이 정사각형인가? false + + 사각형이 정사각형인가? false + + 삼각형이 정사각형인가? false + + */ + + fn main() { + // Shape 타입의 값들을 생성합니다. + let circle = Shape::Circle(2.0); + let rectangle = Shape::Rectangle(3.0, 4.0); + let triangle = Shape::Triangle(3.0, 4.0, 5.0); + + // 각 도형의 넓이를 출력합니다. + println!("원 넓이: {}", area(&circle)); + println!("사각형 넓이: {}", area(&rectangle)); + println!("삼각형 넓이: {}", area(&triangle)); + + // 각 도형의 둘레를 출력합니다. + println!("원 둘레: {}", perimeter(&circle)); + println!("사각형 둘레: {}", perimeter(&rectangle)); + println!("삼각형 둘레: {}", perimeter(&triangle)); + + // 각 도형이 정사각형인지 출력합니다. + println!("원이 정사각형인가? {}", is_square(&circle)); + println!("사각형이 정사각형인가? {}", is_square(&rectangle)); + println!("삼각형이 정사각형인가? {}", is_square(&triangle)); + } + + %end% + </div> + </div>