File tree Expand file tree Collapse file tree 7 files changed +16
-12
lines changed
Expand file tree Collapse file tree 7 files changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ <h1>문자열</h1>
7878< p > &str에서 String으로 소유권을 이전할 때는 to_owned()를 사용하는 것이 일반적인 관례입니다.</ p >
7979< p > 즉, 문자열의 경우에는 두 메소드 모두 String으로의 변환을 수행하지만,</ p >
8080< p > 다른 타입들의 경우에는 to_string()이 문자열 변환을 처리하고, to_owned()는 다른 목적으로 사용됩니다.</ p >
81+ < p > 참고: < a href ="https://rinthel.github.io/rust-lang-book-ko/ch08-02-strings.html " target ="_blank " rel ="noopener "> @Rust 공식 문서</ a > </ p >
8182 < div class ="bottomnav ">
8283 < span class ="back "> < a href ="10_ko.html " rel ="prev "> ❮ 이전</ a > </ span >
8384 < span class ="next "> < a href ="12_ko.html " rel ="next "> 다음 ❯</ a > </ span >
Original file line number Diff line number Diff line change @@ -40,8 +40,8 @@ <h1>Basic Type Conversion</h1>
4040< p > 다행히 Rust는 < strong > as</ strong > 키워드를 사용하여 숫자형을 쉽게 변환할 수 있습니다.</ p >
4141< p > 또는 < code > parse</ code > 를 자주 사용합니다.</ p >
4242< pre > < code class ="rust "> let my_string = "42";
43- let my_integer = my_string.parse::< i32 > ().unwrap();
44- // double colon op, ::< i32 > syntax tells the compiler to parse the string as an i32 type</ code > </ pre >
43+ let my_integer = my_string.parse::< i32> ().unwrap();
44+ // double colon op, ::< i32> syntax tells the compiler to parse the string as an i32 type</ code > </ pre >
4545 < div class ="bottomnav ">
4646 < span class ="back "> < a href ="11_ko.html " rel ="prev "> ❮ 이전</ a > </ span >
4747 < span class ="next "> < a href ="13_ko.html " rel ="next "> 다음 ❯</ a > </ span >
Original file line number Diff line number Diff line change @@ -47,8 +47,8 @@ <h1>Error handling</h1>
4747< p > 예를 들어, 정수를 문자열로 변환하는 간단한 함수를 작성해 봅시다.</ p >
4848< p > 이 함수는 문자열을 입력으로 받아 정수로 변환하려고 시도하고, 변환에 성공하면 Ok 값을 반환합니다.</ p >
4949< p > 만약 변환에 실패하면, Err 값을 반환합니다.</ p >
50- < pre > < code class ="rust "> fn parse_integer(input: &str) -> Result< i32 , String > {
51- match input.parse::< i32 > () {
50+ < pre > < code class ="rust "> fn parse_integer(input: &str) -> Result< i32, String> {
51+ match input.parse::< i32> () {
5252 Ok(value) => Ok(value),
5353 Err(_) => Err(format!("'{}' is not a valid integer.", input)),
5454 }
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ <h1>Chapter 1 - 마무리</h1>
6161 let s = (a + b + c) / 2.0;
6262 let area = s * (s - a) * (s - b) * (s - c);
6363 // 넓이가 음수면 에러 발생
64- if area < 0 .0 {
64+ if area < 0.0 {
6565 panic!("Invalid triangle");
6666 } else {
6767 area.sqrt()
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ <h1>수명</h1>
4747< p > 예제 1: 함수 시그니처에서 수명 표시</ p >
4848< pre > < code class ="rust "> // 여기에서 사용된 'a는 수명을 나타내는 표시입니다.
4949// 이를 통해 입력과 출력의 참조들이 동일한 수명을 가지도록 합니다.
50- fn longest< 'a> (s1: &'a str, s2: &'a str) -> &'a str {
50+ fn longest< 'a> (s1: &'a str, s2: &'a str) -> &'a str {
5151 if s1.len() > s2.len() {
5252 s1
5353 } else {
@@ -57,7 +57,7 @@ <h1>수명</h1>
5757< p > 예제 2: 구조체에서 수명 표시</ p >
5858< pre > < code class ="rust "> // Person 구조체는 이름을 문자열 슬라이스로 저장합니다.
5959// 여기에서 사용된 'a는 구조체의 이름 필드가 참조하는 문자열 슬라이스의 수명을 나타냅니다.
60- struct Person< 'a> {
60+ struct Person< 'a> {
6161 name: &'a str,
6262}</ code > </ pre >
6363< p > 수명과 빌림 검사기:</ p >
Original file line number Diff line number Diff line change @@ -8,7 +8,8 @@ const targetDir = process.argv[3];
88const rustExtension = {
99 type : "lang" ,
1010 regex : / % r u s t % ( [ ^ ] + ?) % e n d % / gi,
11- replace : ( s , match ) => `<pre><code class="rust">${ match . trim ( ) } </code></pre>` ,
11+ replace : ( s , match ) =>
12+ `<pre><code class="rust">${ match . trim ( ) . replace ( "<" , "<" ) } </code></pre>` ,
1213} ;
1314
1415const centerImageExtension = {
Original file line number Diff line number Diff line change 268268
269269
270270 다른 타입들의 경우에는 to\_string()이 문자열 변환을 처리하고, to\_owned()는 다른 목적으로 사용됩니다.
271+
272+
273+ 참고: [@Rust 공식 문서](https://rinthel.github.io/rust-lang-book-ko/ch08-02-strings.html)
271274 - title : Basic Type Conversion
272275 code : >-
273276 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
280283
281284 또는 `parse`를 자주 사용합니다.
282285
283-
284286 %rust%
285287 let my_string = "42";
286288
287- let my_integer = my_string.parse::< i32>().unwrap();
289+ let my_integer = my_string.parse::< i32>().unwrap();
288290
289- // double colon op, ::< i32> syntax tells the compiler to parse the string as an i32 type
291+ // double colon op, ::< i32> syntax tells the compiler to parse the string as an i32 type
290292
291293 %end%
292294 - title : Constants
648650
649651 %rust%
650652 fn parse_integer(input: &str) -> Result<i32, String> {
651- match input.parse::< i32>() {
653+ match input.parse::< i32>() {
652654 Ok(value) => Ok(value),
653655 Err(_) => Err(format!("'{}' is not a valid integer.", input)),
654656 }
You can’t perform that action at this time.
0 commit comments