diff --git a/docs/11_ko.html b/docs/11_ko.html index 04a2f3d3305bc92d3a432a372cdefe18cc1d2f33..9acafa4051e65f554fc8b6265919248b24cb7613 100644 --- a/docs/11_ko.html +++ b/docs/11_ko.html @@ -78,6 +78,7 @@ let my_number_string = my_number.to_string(); // "42"라는 String 타입으로 <p>&str에서 String으로 소유권을 이전할 때는 to_owned()를 사용하는 것이 일반적인 관례입니다.</p> <p>즉, 문자열의 경우에는 두 메소드 모두 String으로의 변환을 수행하지만,</p> <p>다른 타입들의 경우에는 to_string()이 문자열 변환을 처리하고, to_owned()는 다른 목적으로 사용됩니다.</p> +<p>참고: <a href="https://rinthel.github.io/rust-lang-book-ko/ch08-02-strings.html" target="_blank" rel="noopener">@Rust 공식 문서</a></p> <div class="bottomnav"> <span class="back"><a href="10_ko.html" rel="prev">❮ 이전</a></span> <span class="next"><a href="12_ko.html" rel="next">다음 ❯</a></span> diff --git a/docs/12_ko.html b/docs/12_ko.html index 77054351d5c089392971e225f43a8ea698955287..396188bf2549d58cc1829c9ca2608417d0f8a40f 100644 --- a/docs/12_ko.html +++ b/docs/12_ko.html @@ -40,8 +40,8 @@ <p>다행히 Rust는 <strong>as</strong> 키워드를 사용하여 숫자형을 쉽게 변환할 수 있습니다.</p> <p>또는 <code>parse</code>를 자주 사용합니다.</p> <pre><code class="rust">let my_string = "42"; -let my_integer = my_string.parse::<i32>().unwrap(); -// double colon op, ::<i32> syntax tells the compiler to parse the string as an i32 type</code></pre> +let my_integer = my_string.parse::<i32>().unwrap(); +// double colon op, ::<i32> syntax tells the compiler to parse the string as an i32 type</code></pre> <div class="bottomnav"> <span class="back"><a href="11_ko.html" rel="prev">❮ 이전</a></span> <span class="next"><a href="13_ko.html" rel="next">다음 ❯</a></span> diff --git a/docs/20_ko.html b/docs/20_ko.html index 0b8c5f1cae378a3e4d87141a2694ecd4b1fcca59..94142244433fd84f568c2e338405f79149d86793 100644 --- a/docs/20_ko.html +++ b/docs/20_ko.html @@ -47,8 +47,8 @@ Rust에서는 결과를 나타내기 위해 Result 열거형을 사용합니다. <p>예를 들어, 정수를 문자열로 변환하는 간단한 함수를 작성해 봅시다.</p> <p>이 함수는 문자열을 입력으로 받아 정수로 변환하려고 시도하고, 변환에 성공하면 Ok 값을 반환합니다.</p> <p>만약 변환에 실패하면, Err 값을 반환합니다.</p> -<pre><code class="rust">fn parse_integer(input: &str) -> Result<i32, String> { - match input.parse::<i32>() { +<pre><code class="rust">fn parse_integer(input: &str) -> Result<i32, String> { + match input.parse::<i32>() { Ok(value) => Ok(value), Err(_) => Err(format!("'{}' is not a valid integer.", input)), } diff --git a/docs/21_ko.html b/docs/21_ko.html index b7dddb9d7b708bc40b6a50dfbadb36e725c2d0a3..13d134b3fef5c3607ae939496891dc695fb159b7 100644 --- a/docs/21_ko.html +++ b/docs/21_ko.html @@ -61,7 +61,7 @@ fn area(shape: &Shape) -> f64 { let s = (a + b + c) / 2.0; let area = s * (s - a) * (s - b) * (s - c); // 넓이가 음수면 에러 발생 - if area < 0.0 { + if area < 0.0 { panic!("Invalid triangle"); } else { area.sqrt() diff --git a/docs/26_ko.html b/docs/26_ko.html index 730c51ae043da9b37a2d8e07545f350d0edd41d5..fa0bcc69d5fbe85966f80d14fe2e0990dad09432 100644 --- a/docs/26_ko.html +++ b/docs/26_ko.html @@ -47,7 +47,7 @@ <p>예제 1: 함수 시그니처에서 수명 표시</p> <pre><code class="rust">// 여기에서 사용된 'a는 수명을 나타내는 표시입니다. // 이를 통해 입력과 출력의 참조들이 동일한 수명을 가지도록 합니다. -fn longest<'a>(s1: &'a str, s2: &'a str) -> &'a str { +fn longest<'a>(s1: &'a str, s2: &'a str) -> &'a str { if s1.len() > s2.len() { s1 } else { @@ -57,7 +57,7 @@ fn longest<'a>(s1: &'a str, s2: &'a str) -> &'a str { <p>예제 2: 구조체에서 수명 표시</p> <pre><code class="rust">// Person 구조체는 이름을 문자열 슬라이스로 저장합니다. // 여기에서 사용된 'a는 구조체의 이름 필드가 참조하는 문자열 슬라이스의 수명을 나타냅니다. -struct Person<'a> { +struct Person<'a> { name: &'a str, }</code></pre> <p>수명과 빌림 검사기:</p> diff --git a/frontend/generate.js b/frontend/generate.js index eef9fd5b3d5fa13e81933b7f6c4e44913a6a9d7d..882afdf0d6bebb9d1162bed594d20a9265035d02 100644 --- a/frontend/generate.js +++ b/frontend/generate.js @@ -8,7 +8,8 @@ const targetDir = process.argv[3]; const rustExtension = { type: "lang", regex: /%rust%([^]+?)%end%/gi, - replace: (s, match) => `<pre><code class="rust">${match.trim()}</code></pre>`, + replace: (s, match) => + `<pre><code class="rust">${match.trim().replace("<", "<")}</code></pre>`, }; const centerImageExtension = { diff --git a/frontend/lessons/ko/chapter_1.yaml b/frontend/lessons/ko/chapter_1.yaml index 9d2ec891ec369ab61a6ba1fde8c21a213ac0bae0..3d102344517586af34118c78ef96e4263d97d78f 100644 --- a/frontend/lessons/ko/chapter_1.yaml +++ b/frontend/lessons/ko/chapter_1.yaml @@ -268,6 +268,9 @@ 다른 타입들의 경우에는 to\_string()이 문자열 변환을 처리하고, to\_owned()는 다른 목적으로 사용됩니다. + + + 참고: [@Rust 공식 문서](https://rinthel.github.io/rust-lang-book-ko/ch08-02-strings.html) - title: Basic Type Conversion code: >- https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&code=fn%20main()%20%7B%0A%20%20%20%20let%20a%20%3D%2013u8%3B%0A%20%20%20%20let%20b%20%3D%207u32%3B%0A%20%20%20%20let%20c%20%3D%20a%20as%20u32%20%2B%20b%3B%0A%20%20%20%20println!(%22%7B%7D%22%2C%20c)%3B%0A%0A%20%20%20%20let%20t%20%3D%20true%3B%0A%20%20%20%20println!(%22%7B%7D%22%2C%20t%20as%20u8)%3B%0A%7D%0A @@ -280,13 +283,12 @@ 또는 `parse`를 자주 사용합니다. - %rust% let my_string = "42"; - let my_integer = my_string.parse::<i32>().unwrap(); + let my_integer = my_string.parse::<i32>().unwrap(); - // double colon op, ::<i32> syntax tells the compiler to parse the string as an i32 type + // double colon op, ::<i32> syntax tells the compiler to parse the string as an i32 type %end% - title: Constants @@ -648,7 +650,7 @@ %rust% fn parse_integer(input: &str) -> Result<i32, String> { - match input.parse::<i32>() { + match input.parse::<i32>() { Ok(value) => Ok(value), Err(_) => Err(format!("'{}' is not a valid integer.", input)), }