Skip to content
Snippets Groups Projects
Commit 716be533 authored by Alfex4936's avatar Alfex4936
Browse files

Fix html break

parent 00e5eabb
Branches
No related tags found
No related merge requests found
Pipeline #6465 passed
......@@ -78,6 +78,7 @@ let my_number_string = my_number.to_string(); // "42"라는 String 타입으로
<p>&amp;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>
......
......@@ -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::&lt;i32>().unwrap();
// double colon op, ::&lt;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>
......
......@@ -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&lt;i32, String> {
match input.parse::&lt;i32>() {
Ok(value) => Ok(value),
Err(_) => Err(format!("'{}' is not a valid integer.", input)),
}
......
......@@ -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 &lt; 0.0 {
panic!("Invalid triangle");
} else {
area.sqrt()
......
......@@ -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&lt;'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&lt;'a> {
name: &'a str,
}</code></pre>
<p>수명과 빌림 검사기:</p>
......
......@@ -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("<", "&lt;")}</code></pre>`,
};
const centerImageExtension = {
......
......@@ -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::&lt;i32>().unwrap();
// double colon op, ::<i32> syntax tells the compiler to parse the string as an i32 type
// double colon op, ::&lt;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::&lt;i32>() {
Ok(value) => Ok(value),
Err(_) => Err(format!("'{}' is not a valid integer.", input)),
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment