mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-03-05 08:25:26 +02:00
parent
eda4766442
commit
9d99e9b082
124
po/ko.po
124
po/ko.po
@ -6476,6 +6476,16 @@ msgid ""
|
||||
"}\n"
|
||||
"```"
|
||||
msgstr ""
|
||||
"```rust,editable\n"
|
||||
"fn main() {\n"
|
||||
" let numbers = vec![10, 20, 30];\n"
|
||||
" let first: Option<&i8> = numbers.first();\n"
|
||||
" println!(\"first: {first:?}\");\n"
|
||||
"\n"
|
||||
" let idx: Result<usize, usize> = numbers.binary_search(&10);\n"
|
||||
" println!(\"idx: {idx:?}\");\n"
|
||||
"}\n"
|
||||
"```"
|
||||
|
||||
#: src/std/option-result.md:18
|
||||
msgid ""
|
||||
@ -6520,6 +6530,22 @@ msgid ""
|
||||
"}\n"
|
||||
"```"
|
||||
msgstr ""
|
||||
"```rust,editable\n"
|
||||
"fn main() {\n"
|
||||
" let mut s1 = String::new();\n"
|
||||
" s1.push_str(\"Hello\");\n"
|
||||
" println!(\"s1: len = {}, capacity = {}\", s1.len(), s1.capacity());\n"
|
||||
"\n"
|
||||
" let mut s2 = String::with_capacity(s1.len() + 1);\n"
|
||||
" s2.push_str(&s1);\n"
|
||||
" s2.push('!');\n"
|
||||
" println!(\"s2: len = {}, capacity = {}\", s2.len(), s2.capacity());\n"
|
||||
"\n"
|
||||
" let s3 = String::from(\"🇨🇭\");\n"
|
||||
" println!(\"s3: len = {}, number of chars = {}\", s3.len(),\n"
|
||||
" s3.chars().count());\n"
|
||||
"}\n"
|
||||
"```"
|
||||
|
||||
#: src/std/string.md:22
|
||||
msgid ""
|
||||
@ -6583,6 +6609,29 @@ msgid ""
|
||||
"}\n"
|
||||
"```"
|
||||
msgstr ""
|
||||
"```rust,editable\n"
|
||||
"fn main() {\n"
|
||||
" let mut v1 = Vec::new();\n"
|
||||
" v1.push(42);\n"
|
||||
" println!(\"v1: len = {}, capacity = {}\", v1.len(), v1.capacity());\n"
|
||||
"\n"
|
||||
" let mut v2 = Vec::with_capacity(v1.len() + 1);\n"
|
||||
" v2.extend(v1.iter());\n"
|
||||
" v2.push(9999);\n"
|
||||
" println!(\"v2: len = {}, capacity = {}\", v2.len(), v2.capacity());\n"
|
||||
"\n"
|
||||
" // 요소로 벡터를 초기화하는 표준 매크로입니다.\n"
|
||||
" let mut v3 = vec![0, 0, 1, 2, 3, 4];\n"
|
||||
"\n"
|
||||
" // 짝수 요소만 유지합니다.\n"
|
||||
" v3.retain(|x| x % 2 == 0);\n"
|
||||
" println!(\"{v3:?}\");\n"
|
||||
"\n"
|
||||
" // 연속 중복을 삭제합니다.\n"
|
||||
" v3.dedup();\n"
|
||||
" println!(\"{v3:?}\");\n"
|
||||
"}\n"
|
||||
"```"
|
||||
|
||||
#: src/std/vec.md:29
|
||||
msgid ""
|
||||
@ -6651,6 +6700,41 @@ msgid ""
|
||||
"}\n"
|
||||
"```"
|
||||
msgstr ""
|
||||
"```rust,editable\n"
|
||||
"use std::collections::HashMap;\n"
|
||||
"\n"
|
||||
"fn main() {\n"
|
||||
" let mut page_counts = HashMap::new();\n"
|
||||
" page_counts.insert(\"Adventures of Huckleberry Finn\".to_string(), "
|
||||
"207);\n"
|
||||
" page_counts.insert(\"Grimms' Fairy Tales\".to_string(), 751);\n"
|
||||
" page_counts.insert(\"Pride and Prejudice\".to_string(), 303);\n"
|
||||
"\n"
|
||||
" if !page_counts.contains_key(\"Les Misérables\") {\n"
|
||||
" println!(\"We know about {} books, but not Les Misérables.\",\n"
|
||||
" page_counts.len());\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" for book in [\"Pride and Prejudice\", \"Alice's Adventure in "
|
||||
"Wonderland\"] {\n"
|
||||
" match page_counts.get(book) {\n"
|
||||
" Some(count) => println!(\"{book}: {count} pages\"),\n"
|
||||
" None => println!(\"{book} is unknown.\")\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" // 아무것도 찾을 수 없는 경우 .entry() 메서드를 사용하여 값을 삽입합니"
|
||||
"다.\n"
|
||||
" for book in [\"Pride and Prejudice\", \"Alice's Adventure in "
|
||||
"Wonderland\"] {\n"
|
||||
" let page_count: &mut i32 = page_counts.entry(book.to_string())."
|
||||
"or_insert(0);\n"
|
||||
" *page_count += 1;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" println!(\"{page_counts:#?}\");\n"
|
||||
"}\n"
|
||||
"```"
|
||||
|
||||
#: src/std/hashmap.md:38
|
||||
msgid ""
|
||||
@ -6800,6 +6884,19 @@ msgid ""
|
||||
"}\n"
|
||||
"```"
|
||||
msgstr ""
|
||||
"```rust,editable\n"
|
||||
"#[derive(Debug)]\n"
|
||||
"enum List<T> {\n"
|
||||
" Cons(T, Box<List<T>>),\n"
|
||||
" Nil,\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"fn main() {\n"
|
||||
" let list: List<i32> = List::Cons(1, Box::new(List::Cons(2, Box::"
|
||||
"new(List::Nil))));\n"
|
||||
" println!(\"{list:?}\");\n"
|
||||
"}\n"
|
||||
"```"
|
||||
|
||||
#: src/std/box-recursive.md:18
|
||||
msgid ""
|
||||
@ -6982,6 +7079,33 @@ msgid ""
|
||||
"}\n"
|
||||
"```"
|
||||
msgstr ""
|
||||
"```rust,editable\n"
|
||||
"use std::rc::{Rc, Weak};\n"
|
||||
"use std::cell::RefCell;\n"
|
||||
"\n"
|
||||
"#[derive(Debug)]\n"
|
||||
"struct Node {\n"
|
||||
" value: i64,\n"
|
||||
" parent: Option<Weak<RefCell<Node>>>,\n"
|
||||
" children: Vec<Rc<RefCell<Node>>>,\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"fn main() {\n"
|
||||
" let mut root = Rc::new(RefCell::new(Node {\n"
|
||||
" value: 42,\n"
|
||||
" parent: None,\n"
|
||||
" children: vec![],\n"
|
||||
" }));\n"
|
||||
" let child = Rc::new(RefCell::new(Node {\n"
|
||||
" value: 43,\n"
|
||||
" children: vec![],\n"
|
||||
" parent: Some(Rc::downgrade(&root))\n"
|
||||
" }));\n"
|
||||
" root.borrow_mut().children.push(child);\n"
|
||||
"\n"
|
||||
" println!(\"graph: {root:#?}\");\n"
|
||||
"}\n"
|
||||
"```"
|
||||
|
||||
#: src/modules.md:1
|
||||
msgid "# Modules"
|
||||
|
Loading…
x
Reference in New Issue
Block a user