[{"data":1,"prerenderedAt":6098},["ShallowReactive",2],{"/ja-jp/blog/learn-advanced-rust-programming-with-a-little-help-from-ai-code-suggestions":3,"navigation-ja-jp":5318,"banner-ja-jp":5748,"footer-ja-jp":5756,"blog-post-authors-ja-jp-Michael Friedrich":5997,"blog-related-posts-ja-jp-learn-advanced-rust-programming-with-a-little-help-from-ai-code-suggestions":6012,"blog-promotions-ja-jp":6036,"next-steps-ja-jp":6089},{"id":4,"title":5,"authors":6,"body":8,"category":5294,"date":5295,"description":5296,"extension":5297,"externalUrl":5298,"faq":5298,"featured":5299,"heroImage":5300,"meta":5301,"navigation":187,"path":5302,"seo":5303,"slug":5307,"stem":5308,"tags":5309,"template":5315,"updatedDate":5316,"__hash__":5317},"blogPosts/ja-jp/blog/learn-advanced-rust-programming-with-a-little-help-from-ai-code-suggestions.md","AIを活用して学ぶ、Rustの高度なプログラミング",[7],"Michael Friedrich",{"type":9,"value":10,"toc":5257},"minimark",[11,28,36,136,140,153,156,164,171,214,224,232,236,257,260,278,281,296,299,305,308,310,321,350,425,431,443,446,465,506,509,536,539,594,600,615,622,625,639,662,668,675,789,794,797,823,829,835,841,847,850,955,996,1017,1023,1026,1039,1051,1059,1077,1131,1137,1192,1203,1234,1315,1321,1333,1336,1377,1426,1449,1458,1465,1471,1474,1477,1480,1500,1509,1523,1529,1532,1548,1606,1612,1620,1626,1630,1633,1660,1682,1693,1712,1718,1721,1763,1773,1804,1810,1812,1821,1835,1856,2102,2116,2143,2149,2151,2154,2355,2374,2384,2390,2393,2398,2400,2409,2419,2425,2432,2488,2490,2498,2512,2524,2562,2569,2816,2822,2862,2865,2868,2881,2905,2917,2971,2977,2993,2999,3147,3151,3154,3184,3190,3389,3392,3398,3401,3408,3536,3544,3802,3804,3825,3833,3845,3869,3952,3961,4197,4203,4206,4219,4309,4323,4326,4510,4523,4643,4649,4655,4658,4771,4774,4801,4806,4809,4811,4814,4822,4965,5103,5106,5109,5118,5133,5136,5150,5156,5162,5165,5168,5183,5186,5189,5215,5222,5224,5237,5253],[12,13,14,15,21,22,27],"p",{},"20年以上前に新しいプログラミング言語を学び始めたとき、私たちは6枚のCD-ROMからインストールしたVisual Studio 6のMSDNライブラリにアクセスしていました。ペンと紙でアルゴリズムを記録し、設計パターンの本を読み漁り、MSDNで正しい型を調べていましたが、こうした作業に時間がかかることが多々ありました。しかし、リモートコラボレーションや人工知能（AI）の時代が到来し、プログラミング言語の学び方は根本的に変わりました。今では",[16,17,20],"a",{"href":18,"rel":19},"https://about.gitlab.com/blog/quick-start-guide-for-gitlab-workspaces/",[],"リモート開発環境","をすばやく立ち上げて画面を共有し、グループでのプログラミングセッションを行えるようになりました。",[16,23,26],{"href":24,"rel":25},"https://about.gitlab.com/ja-jp/gitlab-duo-agent-platform/",[],"GitLab Duoのコード提案","を使用すれば、AIというインテリジェントなパートナーにいつでも頼ることができます。コード提案機能は、ユーザーのプログラミングのスタイルと経験に基づいて学習します。この機能は、インプットとコンテキストさえあれば、最も効率的な提案を提供してくれるのです。",[12,29,30,31,35],{},"このチュートリアルでは、",[16,32,34],{"href":33},"/blog/learning-rust-with-a-little-help-from-ai-code-suggestions-getting-started/","入門編のブログ記事","（英語）からさらに一歩踏み込み、シンプルなフィードリーダーアプリケーションの設計と作成に取り組みます。",[37,38,39,48,62,70,78,86,89,103,114,125],"ul",{},[40,41,42,43],"li",{},"準備\n",[37,44,45],{},[40,46,47],{},"コード提案",[40,49,50,51],{},"Rustの学習の継続\n",[37,52,53,56,59],{},[40,54,55],{},"「Hello, Reader!」アプリ",[40,57,58],{},"プロジェクトの初期化",[40,60,61],{},"RSSフィードURLの定義",[40,63,64,65],{},"モジュール\n",[37,66,67],{},[40,68,69],{},"main() 関数によるモジュール関数の呼び出し",[40,71,72,73],{},"クレート\n",[37,74,75],{},[40,76,77],{},"feed-rs：XMLフィードの解析",[40,79,80,81],{},"ランタイム設定：プログラム引数\n",[37,82,83],{},[40,84,85],{},"ユーザー入力のエラーハンドリング",[40,87,88],{},"永続性とデータ保存",[40,90,91,92],{},"最適化\n",[37,93,94,97,100],{},[40,95,96],{},"非同期実行",[40,98,99],{},"スレッドの生成",[40,101,102],{},"関数スコープ、スレッド、クロージャ",[40,104,105,106],{},"フィードのXMLの解析およびオブジェクト型への変換\n",[37,107,108,111],{},[40,109,110],{},"汎用的なフィードデータ型のマッピング",[40,112,113],{},"Option::unwrap()によるエラーハンドリング",[40,115,116,117],{},"ベンチマーク\n",[37,118,119,122],{},[40,120,121],{},"逐次実行と並列実行のベンチマークの比較",[40,123,124],{},"Rustのキャッシュを使用したCI/CD",[40,126,127,128],{},"次のステップ\n",[37,129,130,133],{},[40,131,132],{},"非同期学習の演習",[40,134,135],{},"フィードバックの共有",[137,138,139],"h2",{"id":139},"準備",[12,141,142,143,147,148,152],{},"ソースコードを参照する前に、",[16,144,146],{"href":145},"/blog/learning-rust-with-a-little-help-from-ai-code-suggestions-getting-started/#vs-code","VS Code","と",[16,149,151],{"href":150},"/blog/learning-rust-with-a-little-help-from-ai-code-suggestions-getting-started/#development-environment-for-rust","Rustの開発環境","をセットアップしてください。",[154,155,47],"h3",{"id":47},[12,157,158,159,163],{},"実際に提案機能を検証する前に、まずはこの機能の使い方を理解しましょう。GitLab Duoのコード提案は、特定のキーボードショートカットを必要とせず、キーを入力するだけで使用できます。たとえば、コード提案を受け入れるには、",[160,161,162],"code",{},"Tab"," キーを押します。また、新しく作成したコードの方が、既存のコードをリファクタリングしたものよりもエラー発生率が低くなる点も覚えておきましょう。AIは非決定的であるため、一度削除したコード提案は再び同じ形で提示されない可能性があります。コード提案は現在ベータ版であり、GitLabは、同機能が生成するコンテンツの全体的な精度向上に取り組んでいます。",[12,165,166,170],{},[167,168,169],"strong",{},"ヒント","：コード提案の最新リリースでは、複数行の指示文に対応しています。ニーズに合わせて指示文を調整することで、よりよい提案を得ることができます。",[172,173,178],"pre",{"className":174,"code":175,"language":176,"meta":177,"style":177},"language-rust shiki shiki-themes github-light","\n    // Create a function that iterates over the source array\n    // and fetches the data using HTTP from the RSS feed items.\n    // Store the results in a new hash map.\n    // Print the hash map to the terminal.\n\n","rust","",[160,179,180,189,196,202,208],{"__ignoreMap":177},[181,182,185],"span",{"class":183,"line":184},"line",1,[181,186,188],{"emptyLinePlaceholder":187},true,"\n",[181,190,192],{"class":183,"line":191},2,[181,193,195],{"class":194},"sAwPA","    // Create a function that iterates over the source array\n",[181,197,199],{"class":183,"line":198},3,[181,200,201],{"class":194},"    // and fetches the data using HTTP from the RSS feed items.\n",[181,203,205],{"class":183,"line":204},4,[181,206,207],{"class":194},"    // Store the results in a new hash map.\n",[181,209,211],{"class":183,"line":210},5,[181,212,213],{"class":194},"    // Print the hash map to the terminal.\n",[12,215,216,217,219,220,223],{},"VS Code拡張機能のオーバーレイは、提案を提示する際に表示されます。提案された行を受け入れるには ",[160,218,162],{}," キーを使用し、一単語だけ受け入れるには ",[160,221,222],{},"Cmd + 右カーソル"," キーを使用します。さらに、三点リーダーメニューからツールバーを常に表示するオプションを選択することも可能です。",[12,225,226,231],{},[227,228],"img",{"alt":229,"src":230},"VS CodeにおけるGitLab Duoの指示文とコード提案のオーバーレイ","https://res.cloudinary.com/about-gitlab-com/image/upload/v1782398627/blog/Content%20Images/learn-rust-with-ai-code-suggestions-advanced-programming/vs_code_code_suggestions_options_overlay_keep_toolbar.png","{: .shadow}",[137,233,235],{"id":234},"rustの学習の継続","Rustの学習の継続",[12,237,238,239,244,245,250,251,256],{},"では、引き続きRustについて学んでいきましょう。Rustは",[16,240,243],{"href":241,"rel":242},"https://docs.gitlab.com/ja-jp/user/project/repository/code_suggestions/",[],"コード提案でサポートされている言語","のひとつです。",[16,246,249],{"href":247,"rel":248},"https://doc.rust-lang.org/rust-by-example/",[],"Rust by Example","（英語）では、初心者に最適なチュートリアルが提供されており、公式の",[16,252,255],{"href":253,"rel":254},"https://doc.rust-lang.org/book/",[],"Rust Book","（英語）を確認しながら進めると効果的です。どちらのリソースもこのブログの執筆の際に参考にしています。",[154,258,55],{"id":259},"hello-readerアプリ",[12,261,262,263,266,267,272,273,277],{},"アプリケーションの作成やRustの学習には、さまざまなアプローチがあります。その中には、既存のRustライブラリ、いわゆる ",[160,264,265],{},"Crates"," を利用するものがあり、このブログ記事の後半でも使用します。たとえば、画像を処理して、その結果をファイルに書き込むコマンドラインアプリを作成することができます。また、昔ながらの迷路をクリアしたり、数独を解いたりするアプリケーションを作成するのも楽しいでしょうし、ゲーム開発を行うこともできます。たとえば、",[16,268,271],{"href":269,"rel":270},"https://hands-on-rust.com/",[],"Hands-on Rust","（英語）というガイドブックでは、ダンジョンクローラー（迷宮探検）ゲームを作りながら、Rustを体系的に学習できるコースを提供しています。筆者の同僚であるFatima Sarah Khalidは、",[16,274,276],{"href":275},"/blog/building-a-text-adventure-using-cplusplus-and-code-suggestions/","AIを活用してC++でDragon Realmの制作","（英語）を始めたそうです。ぜひそちらもご覧ください。",[12,279,280],{},"ここで、実際の問題を解決するのに役立つ実用的なユースケースをひとつご紹介します。それは、異なるソースから重要な情報をRSSフィードに集約するというものです。RSSフィードには、セキュリティリリース、ブログ記事、およびソーシャルディスカッションフォーラム（Hacker Newsなど）の最新情報が含まれます。アップデートに含まれる特定のキーワードやバージョンを絞り込んで検索したいと考えることがよくあります。こうしたニーズを基に、アプリケーションの要件をリスト化できます。具体的には、次のような要件です。",[282,283,284,287,290,293],"ol",{},[40,285,286],{},"HTTPウェブサイト、REST API、RSSフィードなどの異なるソースからデータをフェッチ（取得）する（最初の段階ではRSSフィードを使用）。",[40,288,289],{},"データを解析する。",[40,291,292],{},"データをユーザーに提示する、またはディスクに書き込む。",[40,294,295],{},"パフォーマンスを最適化する。",[12,297,298],{},"このブログ記事の学習ステップを完了すると、以下のサンプルアプリケーションの出力が得られます。",[12,300,301],{},[227,302],{"alt":303,"src":304},"VS Codeのターミナルでのcargo runの実行と、形成されたフィードエントリの出力","https://res.cloudinary.com/about-gitlab-com/image/upload/v1782398628/blog/Content%20Images/learn-rust-with-ai-code-suggestions-advanced-programming/vs_code_terminal_cargo_run_formatted_output_final.png",[12,306,307],{},"アプリケーションはモジュール化されている必要があり、また、将来的にデータ型やフィルター、アクションをトリガーするフックを追加できる基盤も整えておく必要があります。",[154,309,58],{"id":58},[12,311,312,313,316,317,320],{},"リマインダー：",[160,314,315],{},"cargo init"," をプロジェクトのルートディレクトリで実行すると、 ",[160,318,319],{},"main ()"," エントリポイントを含んだファイル構造が作成されます。これを踏まえ、次のステップでは、Rustのモジュールの作成と使用方法を学びます。",[12,322,323,326,327,329,330,333,334,337,338,343,344,349],{},[160,324,325],{},"learn-rust-ai-app-reader"," という名前のディレクトリを新規作成し、そのディレクトリに移動したら、",[160,328,315],{}," を実行します。このコマンドは、暗黙的に ",[160,331,332],{},"git init"," を実行し、新しいGitリポジトリをローカルで初期化します。残りのステップでは、Gitリモートリポジトリのパスを設定していきます。たとえば、",[160,335,336],{},"https://gitlab.com/gitlab-da/use-cases/ai/learn-with-ai/learn-rust-ai-app-reader"," のように設定します（ご自身のネームスペースに合わせてパスを置き換えてください）。",[16,339,342],{"href":340,"rel":341},"https://about.gitlab.com/ja-jp/blog/mastering-the-basics-of-git-push-tag/",[],"Gitリポジトリをプッシュ","すると、",[16,345,348],{"href":346,"rel":347},"https://docs.gitlab.com/ja-jp/user/project/#create-a-new-project-with-git-push",[],"GitLabで新しいプロジェクトが自動的に作成","されます。",[172,351,355],{"className":352,"code":353,"language":354,"meta":177,"style":177},"language-shell shiki shiki-themes github-light","mkdir learn-rust-ai-app-reader\ncd learn-rust-ai-app-reader\n\ncargo init\n\ngit remote add origin https://gitlab.com/gitlab-da/use-cases/ai/learn-with-ai/learn-rust-ai-app-reader.git\ngit push --set-upstream origin main\n","shell",[160,356,357,367,375,379,387,391,409],{"__ignoreMap":177},[181,358,359,363],{"class":183,"line":184},[181,360,362],{"class":361},"s7eDp","mkdir",[181,364,366],{"class":365},"sYBdl"," learn-rust-ai-app-reader\n",[181,368,369,373],{"class":183,"line":191},[181,370,372],{"class":371},"sYu0t","cd",[181,374,366],{"class":365},[181,376,377],{"class":183,"line":198},[181,378,188],{"emptyLinePlaceholder":187},[181,380,381,384],{"class":183,"line":204},[181,382,383],{"class":361},"cargo",[181,385,386],{"class":365}," init\n",[181,388,389],{"class":183,"line":210},[181,390,188],{"emptyLinePlaceholder":187},[181,392,394,397,400,403,406],{"class":183,"line":393},6,[181,395,396],{"class":361},"git",[181,398,399],{"class":365}," remote",[181,401,402],{"class":365}," add",[181,404,405],{"class":365}," origin",[181,407,408],{"class":365}," https://gitlab.com/gitlab-da/use-cases/ai/learn-with-ai/learn-rust-ai-app-reader.git\n",[181,410,412,414,417,420,422],{"class":183,"line":411},7,[181,413,396],{"class":361},[181,415,416],{"class":365}," push",[181,418,419],{"class":371}," --set-upstream",[181,421,405],{"class":365},[181,423,424],{"class":365}," main\n",[12,426,427,428,430],{},"新しく作成されたディレクトリからVS Codeを開きます。",[160,429,160],{}," コマンドラインインターフェース（CLI）によって、macOS上で新しいVS Codeのウィンドウが起動します。",[172,432,434],{"className":352,"code":433,"language":354,"meta":177,"style":177},"code .\n",[160,435,436],{"__ignoreMap":177},[181,437,438,440],{"class":183,"line":184},[181,439,160],{"class":361},[181,441,442],{"class":365}," .\n",[154,444,61],{"id":445},"rssフィードurlの定義",[12,447,448,449,452,453,456,457,464],{},"新しいHashMapを追加して、",[160,450,451],{},"src/main.rs"," ファイル内の ",[160,454,455],{},"main()"," 関数にRSSフィードのURLを保存します。複数行の指示コメントを入力することで、GitLab Duoのコード提案に対し、",[16,458,461],{"href":459,"rel":460},"https://doc.rust-lang.org/stable/std/collections/struct.HashMap.html",[],[160,462,463],{},"HashMap"," オブジェクトを作成して、Hacker NewsやTechCrunchのデフォルト値で初期化するよう指示できます。注：提案に含まれるURLが正しいことを確認してください。",[172,466,468],{"className":174,"code":467,"language":176,"meta":177,"style":177},"fn main() {##$_0A$##    // Define RSS feed URLs in the variable rss_feeds##$_0A$##    // Use a HashMap##$_0A$##    // Add Hacker News and TechCrunch##$_0A$##    // Ensure to use String as type##$_0A$####$_0A$##}\n",[160,469,470],{"__ignoreMap":177},[181,471,472,476,479,483,486,489,491,494,497,500,503],{"class":183,"line":184},[181,473,475],{"class":474},"sD7c4","fn",[181,477,478],{"class":361}," main",[181,480,482],{"class":481},"sgsFI","() {##",[181,484,485],{"class":474},"$",[181,487,488],{"class":481},"_0A",[181,490,485],{"class":474},[181,492,493],{"class":481},"##    ",[181,495,496],{"class":194},"// Define RSS feed URLs in the variable rss_feeds##$_0A$##",[181,498,499],{"class":194},"    // Use a HashMap##$_0A$##",[181,501,502],{"class":194},"    // Add Hacker News and TechCrunch##$_0A$##",[181,504,505],{"class":194},"    // Ensure to use String as type##$_0A$####$_0A$##}\n",[12,507,508],{},"コードコメントでは以下の点を指示しています。",[282,510,511,517,522,529],{},[40,512,513,514],{},"変数名 ",[160,515,516],{},"rss_feeds",[40,518,519,521],{},[160,520,463],{}," タイプ",[40,523,524],{},[282,525,526],{"start":198},[40,527,528],{},"初期のseedキー/バリューペア",[40,530,531,532,535],{},"String 型（",[160,533,534],{},"to_string ()"," 呼び出しで確認可能）",[12,537,538],{},"考えられるコードの例は次の通りです。",[172,540,542],{"className":174,"code":541,"language":176,"meta":177,"style":177},"use std::collections::HashMap;\n\nfn main() {##$_0A$##    // Define RSS feed URLs in the variable rss_feeds##$_0A$##    // Use a HashMap##$_0A$##    // Add Hacker News and TechCrunch##$_0A$##    // Ensure to use String as type##$_0A$##    let rss_feeds = HashMap::from([##$_0A$##        (\"Hacker News\".to_string(), \"https://news.ycombinator.com/rss\".to_string()),##$_0A$## (\"TechCrunch\".to_string(), \"https://techcrunch.com/feed/\".to_string()),##$_0A$## ]);##$_0A$####$_0A$##}\n",[160,543,544,565,569],{"__ignoreMap":177},[181,545,546,549,552,555,558,560,562],{"class":183,"line":184},[181,547,548],{"class":474},"use",[181,550,551],{"class":361}," std",[181,553,554],{"class":474},"::",[181,556,557],{"class":361},"collections",[181,559,554],{"class":474},[181,561,463],{"class":361},[181,563,564],{"class":481},";\n",[181,566,567],{"class":183,"line":191},[181,568,188],{"emptyLinePlaceholder":187},[181,570,571,573,575,577,579,581,583,585,587,589,591],{"class":183,"line":198},[181,572,475],{"class":474},[181,574,478],{"class":361},[181,576,482],{"class":481},[181,578,485],{"class":474},[181,580,488],{"class":481},[181,582,485],{"class":474},[181,584,493],{"class":481},[181,586,496],{"class":194},[181,588,499],{"class":194},[181,590,502],{"class":194},[181,592,593],{"class":194},"    // Ensure to use String as type##$_0A$##    let rss_feeds = HashMap::from([##$_0A$##        (\"Hacker News\".to_string(), \"https://news.ycombinator.com/rss\".to_string()),##$_0A$## (\"TechCrunch\".to_string(), \"https://techcrunch.com/feed/\".to_string()),##$_0A$## ]);##$_0A$####$_0A$##}\n",[12,595,596],{},[227,597],{"alt":598,"src":599},"VS Codeにおける、コード提案を活用したHacker NewsとTechCrunchのRSSフィードURLの提案","https://res.cloudinary.com/about-gitlab-com/image/upload/v1782398627/blog/Content%20Images/learn-rust-with-ai-code-suggestions-advanced-programming/vs_code_main_array_rss_feed_urls_suggested.png",[12,601,602,603,606,607,610,611,614],{},"VS Codeで新しいターミナルを開き（cmd + shift + p で ",[160,604,605],{},"terminal"," を検索）、",[160,608,609],{},"cargo build"," を実行して変更をビルドします。エラーメッセージが表示され、",[160,612,613],{},"use std::collections::HashMap;"," のインポートを追加するよう指示されます。",[12,616,617,618,621],{},"次のステップでは、RSSフィードのURLを使用して操作を行います。",[16,619,620],{"href":33},"以前のブログ記事","（英語）では、コードを関数に分割する方法を解説しました。今回は、リーダーアプリケーションのコードをよりモジュール化して整理し、Rustのモジュールを使用します。",[137,623,624],{"id":624},"モジュール",[12,626,627,631,632,634,635,638],{},[16,628,624],{"href":629,"rel":630},"https://doc.rust-lang.org/rust-by-example/mod.html",[],"は、 コードの整理に役立ちます。また、関数をモジュールのスコープ内に隠し、main()スコープからのアクセスを制限することも可能です。リーダーアプリケーションでは、RSSフィードのコンテンツを取得し、XMLレスポンスを解析したいため、",[160,633,455],{}," からは、",[160,636,637],{},"get_feeds()"," 関数のみにアクセスできるようにし、それ以外の機能はモジュール内のみで使用できるように制限します。",[12,640,641,644,645,648,649,652,653,655,656,661],{},[160,642,643],{},"src/"," ディレクトリに ",[160,646,647],{},"feed_reader.rs"," という名前の新しいファイルを作成します。コード提案に、",[160,650,651],{},"feed_reader"," という名前の公開モジュールと、String HashMapをインプットとして受け取る ",[160,654,637],{}," という公開関数を作成するよう指示します。重要：",[16,657,660],{"href":658,"rel":659},"https://doc.rust-lang.org/book/ch07-02-defining-modules-to-control-scope-and-privacy.html",[],"Rustのモジュール構造","に従って、ファイル名とモジュール名を同じにする必要があります。",[12,663,664,231],{},[227,665],{"alt":666,"src":667},"コード提案：関数と入力型を使った公開モジュールの作成","https://res.cloudinary.com/about-gitlab-com/image/upload/v1782398624/blog/Content%20Images/learn-rust-with-ai-code-suggestions-advanced-programming/code_suggestions_rust_public_module_function_input.png",[12,669,670,671,674],{},"コード提案に入力変数名と型を指定すると、必要な ",[160,672,673],{},"std::collections::HashMap"," モジュールが自動的にインポートされます。ヒント：最適な結果を得られるよう、コメントを使って変数の型を調整してみましょう。また、Rustでは関数のパラメータをオブジェクト参照として渡すのがベストプラクティスとされています。以下に例を示します。",[172,676,678],{"className":174,"code":677,"language":176,"meta":177,"style":177},"// Create public module feed_reader\n// Define get_feeds() function which takes rss_feeds as String HashMap reference as input\npub mod feed_reader {##$_0A$##    use std::collections::HashMap;##$_0A$####$_0A$##    pub fn get_feeds(rss_feeds: &HashMap\u003CString, String>) {##$_0A$##        // Do something with the RSS feeds##$_0A$##    }##$_0A$##}\n",[160,679,680,685,690],{"__ignoreMap":177},[181,681,682],{"class":183,"line":184},[181,683,684],{"class":194},"// Create public module feed_reader\n",[181,686,687],{"class":183,"line":191},[181,688,689],{"class":194},"// Define get_feeds() function which takes rss_feeds as String HashMap reference as input\n",[181,691,692,695,698,701,704,706,708,710,712,714,716,718,720,722,724,727,729,731,733,736,738,740,742,744,746,749,752,755,758,761,763,766,769,772,774,777,779,781,783,786],{"class":183,"line":198},[181,693,694],{"class":474},"pub",[181,696,697],{"class":474}," mod",[181,699,700],{"class":361}," feed_reader",[181,702,703],{"class":481}," {##",[181,705,485],{"class":474},[181,707,488],{"class":481},[181,709,485],{"class":474},[181,711,493],{"class":481},[181,713,548],{"class":474},[181,715,551],{"class":361},[181,717,554],{"class":474},[181,719,557],{"class":361},[181,721,554],{"class":474},[181,723,463],{"class":361},[181,725,726],{"class":481},";##",[181,728,485],{"class":474},[181,730,488],{"class":481},[181,732,485],{"class":474},[181,734,735],{"class":481},"####",[181,737,485],{"class":474},[181,739,488],{"class":481},[181,741,485],{"class":474},[181,743,493],{"class":481},[181,745,694],{"class":474},[181,747,748],{"class":474}," fn",[181,750,751],{"class":361}," get_feeds",[181,753,754],{"class":481},"(rss_feeds",[181,756,757],{"class":474},":",[181,759,760],{"class":474}," &",[181,762,463],{"class":361},[181,764,765],{"class":481},"\u003C",[181,767,768],{"class":361},"String",[181,770,771],{"class":481},", ",[181,773,768],{"class":361},[181,775,776],{"class":481},">) {##",[181,778,485],{"class":474},[181,780,488],{"class":481},[181,782,485],{"class":474},[181,784,785],{"class":481},"##        ",[181,787,788],{"class":194},"// Do something with the RSS feeds##$_0A$##    }##$_0A$##}\n",[12,790,791,231],{},[227,792],{"alt":793,"src":667},"コード提案：get_feeds() 関数と提案された入力変数を含む公開モジュール",[12,795,796],{},"関数内では、コード提案に以下の手順を指示します。",[282,798,799,805,811,817],{},[40,800,801,804],{},[160,802,803],{},"// Iterate over the RSS feed URLs"," （RSSフィードURLを反復処理する）",[40,806,807,810],{},[160,808,809],{},"// Fetch URL content"," （URLコンテンツを取得する）",[40,812,813,816],{},[160,814,815],{},"// Parse XML body"," （XMLの本文を解析する）",[40,818,819,822],{},[160,820,821],{},"// Print the result","  (結果を出力する)",[12,824,825,231],{},[227,826],{"alt":827,"src":828},"コード提案：get_feeds() 関数を含む公開モジュール、ステップ1：イテレート","https://res.cloudinary.com/about-gitlab-com/image/upload/v1782398622/blog/Content%20Images/learn-rust-with-ai-code-suggestions-advanced-programming/code_suggestions_rust_module_function_01_iterate.png",[12,830,831,231],{},[227,832],{"alt":833,"src":834},"コード提案：get_feeds() 関数を含む公開モジュール、ステップ2：URLコンテンツの取得","https://res.cloudinary.com/about-gitlab-com/image/upload/v1782398622/blog/Content%20Images/learn-rust-with-ai-code-suggestions-advanced-programming/code_suggestions_rust_module_function_02_fetch_content.png",[12,836,837,231],{},[227,838],{"alt":839,"src":840},"コード提案：get_feeds() 関数を含む公開モジュール、ステップ3：XML本文の解析","https://res.cloudinary.com/about-gitlab-com/image/upload/v1782398622/blog/Content%20Images/learn-rust-with-ai-code-suggestions-advanced-programming/code_suggestions_rust_module_function_03_parse_body.png",[12,842,843,231],{},[227,844],{"alt":845,"src":846},"コード提案：get_feeds() 関数を含む公開モジュール、ステップ4：結果の出力","https://res.cloudinary.com/about-gitlab-com/image/upload/v1782398623/blog/Content%20Images/learn-rust-with-ai-code-suggestions-advanced-programming/code_suggestions_rust_module_function_04_print_result.png",[12,848,849],{},"次のコードが提案されます。",[172,851,853],{"className":174,"code":852,"language":176,"meta":177,"style":177},"// Create public module feed_reader\n// Define get_feeds() function which takes rss_feeds as String HashMap reference as input\npub mod feed_reader {##$_0A$##    use std::collections::HashMap;##$_0A$####$_0A$##    pub fn get_feeds(rss_feeds: &HashMap\u003CString, String>) {##$_0A$##        // Iterate over the RSS feed URLs##$_0A$##        for (name, url) in rss_feeds {##$_0A$## println!(\"{}: {}\", name, url);##$_0A$####$_0A$##            // Fetch URL content##$_0A$##            let body = reqwest::blocking::get(url).unwrap().text().unwrap();##$_0A$####$_0A$## // Parse XML body##$_0A$##            let parsed_body = roxmltree::Document::parse(&body).unwrap();##$_0A$####$_0A$##            // Print the result##$_0A$##            println!(\"{:#?}\", parsed_body);##$_0A$##        }##$_0A$##    }##$_0A$##}\n",[160,854,855,859,863],{"__ignoreMap":177},[181,856,857],{"class":183,"line":184},[181,858,684],{"class":194},[181,860,861],{"class":183,"line":191},[181,862,689],{"class":194},[181,864,865,867,869,871,873,875,877,879,881,883,885,887,889,891,893,895,897,899,901,903,905,907,909,911,913,915,917,919,921,923,925,927,929,931,933,935,937,939,941,943,946,949,952],{"class":183,"line":198},[181,866,694],{"class":474},[181,868,697],{"class":474},[181,870,700],{"class":361},[181,872,703],{"class":481},[181,874,485],{"class":474},[181,876,488],{"class":481},[181,878,485],{"class":474},[181,880,493],{"class":481},[181,882,548],{"class":474},[181,884,551],{"class":361},[181,886,554],{"class":474},[181,888,557],{"class":361},[181,890,554],{"class":474},[181,892,463],{"class":361},[181,894,726],{"class":481},[181,896,485],{"class":474},[181,898,488],{"class":481},[181,900,485],{"class":474},[181,902,735],{"class":481},[181,904,485],{"class":474},[181,906,488],{"class":481},[181,908,485],{"class":474},[181,910,493],{"class":481},[181,912,694],{"class":474},[181,914,748],{"class":474},[181,916,751],{"class":361},[181,918,754],{"class":481},[181,920,757],{"class":474},[181,922,760],{"class":474},[181,924,463],{"class":361},[181,926,765],{"class":481},[181,928,768],{"class":361},[181,930,771],{"class":481},[181,932,768],{"class":361},[181,934,776],{"class":481},[181,936,485],{"class":474},[181,938,488],{"class":481},[181,940,485],{"class":474},[181,942,785],{"class":481},[181,944,945],{"class":194},"// Iterate over the RSS feed URLs##$_0A$##        for (name, url) in rss_feeds {##$_0A$## println!(\"{}: {}\", name, url);##$_0A$####$_0A$##",[181,947,948],{"class":194},"            // Fetch URL content##$_0A$##            let body = reqwest::blocking::get(url).unwrap().text().unwrap();##$_0A$####$_0A$##",[181,950,951],{"class":194}," // Parse XML body##$_0A$##            let parsed_body = roxmltree::Document::parse(&body).unwrap();##$_0A$####$_0A$##",[181,953,954],{"class":194},"            // Print the result##$_0A$##            println!(\"{:#?}\", parsed_body);##$_0A$##        }##$_0A$##    }##$_0A$##}\n",[12,956,957,958,965,966,969,970,978,979,982,983,985,986,988,989,992,993,995],{},"ここで新しいキーワード ",[16,959,962],{"href":960,"rel":961},"https://doc.rust-lang.org/rust-by-example/error/option_unwrap.html",[],[160,963,964],{},"unwrap()","が登場します。Rustは ",[160,967,968],{},"null"," 値をサポートしておらず、すべての値に対して ",[16,971,974,977],{"href":972,"rel":973},"https://doc.rust-lang.org/rust-by-example/std/option.html",[],[160,975,976],{},"Option"," 型","を使用します。たとえば、",[160,980,981],{},"Text"," や ",[160,984,768],{}," といった特定のラップされた型を使用することが確定している場合、",[160,987,964],{}," メソッドを呼び出してその値を取得できます。ただし、値が ",[160,990,991],{},"None"," の場合、",[160,994,964],{}," メソッドはパニックを起こします。",[12,997,998,1001,1002,1004,1005,1008,1009,1016],{},[167,999,1000],{},"注意","：コード提案は、",[160,1003,809],{}," のコメント指示に従って、",[160,1006,1007],{},"reqwest::blocking::get"," 関数を参照します。",[16,1010,1013],{"href":1011,"rel":1012},"https://docs.rs/reqwest/latest/reqwest/",[],[160,1014,1015],{},"reqwest","というクレーと名は意図的なものであり、タイポではありません。非同期リクエストとブロッキングリクエストの処理に役立つ、優れた利便性と高レベルのHTTPクライアントの機能を提供します。",[12,1018,1019,1020,1022],{},"XMLの本文の解析は難しく、異なる結果が得られることがあります。また、スキーマはRSSフィードURLごとに異なる可能性があります。まずは ",[160,1021,637],{}," 関数を呼び出し、その後でコードの改善に取り組みましょう。",[154,1024,69],{"id":1025},"main-関数によるモジュール関数の呼び出し",[12,1027,1028,1029,1031,1032,982,1035,1038],{},"現在、main() 関数は ",[160,1030,637],{}," 関数を認識していないため、まずそのモジュールをインポートする必要があります。他のプログラミング言語では ",[160,1033,1034],{},"include",[160,1036,1037],{},"import"," といったキーワードを目にすることがありますが、Rustのモジュールシステムは異なります。",[12,1040,1041,1042,1044,1045,1047,1048,1050],{},"モジュールはパスディレクトリに整理されます。今回の例では、両方のソースファイルが同じディレクトリレベルに存在しています。",[160,1043,647],{}," はクレートとして解釈され、その中に ",[160,1046,651],{}," というモジュールがあり、そのモジュールが ",[160,1049,637],{}," 関数を定義しています。",[172,1052,1057],{"className":1053,"code":1055,"language":1056,"meta":177},[1054],"language-text","src/\n  main.rs\n  feed_reader.rs\n\n","text",[160,1058,1055],{"__ignoreMap":177},[12,1060,1061,1063,1064,1066,1067,1070,1071,1076],{},[160,1062,647],{}," ファイルの ",[160,1065,637],{}," 関数にアクセスするためには、まず ",[160,1068,1069],{},"main.rs"," のスコープに",[16,1072,1075],{"href":1073,"rel":1074},"https://doc.rust-lang.org/book/ch07-04-bringing-paths-into-scope-with-the-use-keyword.html",[],"モジュールパスを取り込み","、その後フルパスで関数を呼び出します。",[172,1078,1080],{"className":174,"code":1079,"language":176,"meta":177,"style":177},"mod feed_reader;\n\nfn main() {\n\n    feed_reader::feed_reader::get_feeds(&rss_feeds);\n\n",[160,1081,1082,1091,1095,1104,1108],{"__ignoreMap":177},[181,1083,1084,1087,1089],{"class":183,"line":184},[181,1085,1086],{"class":474},"mod",[181,1088,700],{"class":361},[181,1090,564],{"class":481},[181,1092,1093],{"class":183,"line":191},[181,1094,188],{"emptyLinePlaceholder":187},[181,1096,1097,1099,1101],{"class":183,"line":198},[181,1098,475],{"class":474},[181,1100,478],{"class":361},[181,1102,1103],{"class":481},"() {\n",[181,1105,1106],{"class":183,"line":204},[181,1107,188],{"emptyLinePlaceholder":187},[181,1109,1110,1113,1115,1117,1119,1122,1125,1128],{"class":183,"line":210},[181,1111,1112],{"class":361},"    feed_reader",[181,1114,554],{"class":474},[181,1116,651],{"class":361},[181,1118,554],{"class":474},[181,1120,1121],{"class":361},"get_feeds",[181,1123,1124],{"class":481},"(",[181,1126,1127],{"class":474},"&",[181,1129,1130],{"class":481},"rss_feeds);\n",[12,1132,1133,1134,1136],{},"あるいは、",[160,1135,548],{}," キーワードを使って関数のフルパスをインポートし、その後短い関数名で呼び出すこともできます。",[172,1138,1140],{"className":174,"code":1139,"language":176,"meta":177,"style":177},"mod feed_reader;\nuse feed_reader::feed_reader::get_feeds;\n\nfn main() {\n\n    get_feeds(&rss_feeds);\n\n",[160,1141,1142,1150,1165,1169,1177,1181],{"__ignoreMap":177},[181,1143,1144,1146,1148],{"class":183,"line":184},[181,1145,1086],{"class":474},[181,1147,700],{"class":361},[181,1149,564],{"class":481},[181,1151,1152,1154,1156,1158,1160,1162],{"class":183,"line":191},[181,1153,548],{"class":474},[181,1155,700],{"class":361},[181,1157,554],{"class":474},[181,1159,651],{"class":361},[181,1161,554],{"class":474},[181,1163,1164],{"class":481},"get_feeds;\n",[181,1166,1167],{"class":183,"line":198},[181,1168,188],{"emptyLinePlaceholder":187},[181,1170,1171,1173,1175],{"class":183,"line":204},[181,1172,475],{"class":474},[181,1174,478],{"class":361},[181,1176,1103],{"class":481},[181,1178,1179],{"class":183,"line":210},[181,1180,188],{"emptyLinePlaceholder":187},[181,1182,1183,1186,1188,1190],{"class":183,"line":393},[181,1184,1185],{"class":361},"    get_feeds",[181,1187,1124],{"class":481},[181,1189,1127],{"class":474},[181,1191,1130],{"class":481},[12,1193,1194,1196,1197,1202],{},[167,1195,169],{},"：Rustのモジュールシステムを視覚的によりよく理解するために、",[16,1198,1201],{"href":1199,"rel":1200},"https://www.sheshbabu.com/posts/rust-module-system/",[],"Rustモジュールシステムについてわかりやすく説明したブログ記事","（英語）をお読みください。",[172,1204,1208],{"className":1205,"code":1206,"language":1207,"meta":177,"style":177},"language-diff shiki shiki-themes github-light","fn main() {\n    // ...\n\n    // Print feed_reader get_feeds() output\n    println!(\"{}\", feed_reader::get_feeds(&rss_feeds));\n\n","diff",[160,1209,1210,1215,1220,1224,1229],{"__ignoreMap":177},[181,1211,1212],{"class":183,"line":184},[181,1213,1214],{"class":481},"fn main() {\n",[181,1216,1217],{"class":183,"line":191},[181,1218,1219],{"class":481},"    // ...\n",[181,1221,1222],{"class":183,"line":198},[181,1223,188],{"emptyLinePlaceholder":187},[181,1225,1226],{"class":183,"line":204},[181,1227,1228],{"class":481},"    // Print feed_reader get_feeds() output\n",[181,1230,1231],{"class":183,"line":210},[181,1232,1233],{"class":481},"    println!(\"{}\", feed_reader::get_feeds(&rss_feeds));\n",[172,1235,1237],{"className":174,"code":1236,"language":176,"meta":177,"style":177},"use std::collections::HashMap;\n\nmod feed_reader;\n// Alternative: Import full function path\n//use feed_reader::feed_reader::get_feeds;\n\nfn main() {##$_0A$##    // Define RSS feed URLs in the variable rss_feeds##$_0A$##    // Use a HashMap##$_0A$##    // Add Hacker News and TechCrunch##$_0A$##    // Ensure to use String as type##$_0A$##    let rss_feeds = HashMap::from([##$_0A$##        (\"Hacker News\".to_string(), \"https://news.ycombinator.com/rss\".to_string()),##$_0A$## (\"TechCrunch\".to_string(), \"https://techcrunch.com/feed/\".to_string()),##$_0A$## ]);##$_0A$####$_0A$##    // Call get_feeds() from feed_reader module##$_0A$## feed_reader::feed_reader::get_feeds(&rss_feeds);##$_0A$##    // Alternative: Imported full path, use short path here.##$_0A$## //get_feeds(&rss_feeds);##$_0A$##}\n",[160,1238,1239,1255,1259,1267,1272,1277,1281],{"__ignoreMap":177},[181,1240,1241,1243,1245,1247,1249,1251,1253],{"class":183,"line":184},[181,1242,548],{"class":474},[181,1244,551],{"class":361},[181,1246,554],{"class":474},[181,1248,557],{"class":361},[181,1250,554],{"class":474},[181,1252,463],{"class":361},[181,1254,564],{"class":481},[181,1256,1257],{"class":183,"line":191},[181,1258,188],{"emptyLinePlaceholder":187},[181,1260,1261,1263,1265],{"class":183,"line":198},[181,1262,1086],{"class":474},[181,1264,700],{"class":361},[181,1266,564],{"class":481},[181,1268,1269],{"class":183,"line":204},[181,1270,1271],{"class":194},"// Alternative: Import full function path\n",[181,1273,1274],{"class":183,"line":210},[181,1275,1276],{"class":194},"//use feed_reader::feed_reader::get_feeds;\n",[181,1278,1279],{"class":183,"line":393},[181,1280,188],{"emptyLinePlaceholder":187},[181,1282,1283,1285,1287,1289,1291,1293,1295,1297,1299,1301,1303,1306,1309,1312],{"class":183,"line":411},[181,1284,475],{"class":474},[181,1286,478],{"class":361},[181,1288,482],{"class":481},[181,1290,485],{"class":474},[181,1292,488],{"class":481},[181,1294,485],{"class":474},[181,1296,493],{"class":481},[181,1298,496],{"class":194},[181,1300,499],{"class":194},[181,1302,502],{"class":194},[181,1304,1305],{"class":194},"    // Ensure to use String as type##$_0A$##    let rss_feeds = HashMap::from([##$_0A$##        (\"Hacker News\".to_string(), \"https://news.ycombinator.com/rss\".to_string()),##$_0A$## (\"TechCrunch\".to_string(), \"https://techcrunch.com/feed/\".to_string()),##$_0A$## ]);##$_0A$####$_0A$##",[181,1307,1308],{"class":194},"    // Call get_feeds() from feed_reader module##$_0A$## feed_reader::feed_reader::get_feeds(&rss_feeds);##$_0A$##",[181,1310,1311],{"class":194},"    // Alternative: Imported full path, use short path here.##$_0A$##",[181,1313,1314],{"class":194}," //get_feeds(&rss_feeds);##$_0A$##}\n",[12,1316,1317,1318,1320],{},"ターミナルで ",[160,1319,609],{}," を再実行しコードをビルドします。",[172,1322,1324],{"className":352,"code":1323,"language":354,"meta":177,"style":177},"cargo build\n",[160,1325,1326],{"__ignoreMap":177},[181,1327,1328,1330],{"class":183,"line":184},[181,1329,383],{"class":361},[181,1331,1332],{"class":365}," build\n",[12,1334,1335],{},"以下は、HTTPリクエストやXML解析に関する一般的なコードを参照した際に発生する可能性のあるビルドエラーの例です。",[282,1337,1338,1360,1369],{},[40,1339,1340,1341,1344,1345,1348,1349,1351,1352,1355,1356,1359],{},"エラー： ",[160,1342,1343],{},"could not find blocking in reqwest","\n解決策：",[160,1346,1347],{},"Config.toml"," ファイルで ",[160,1350,1015],{}," クレートの ",[160,1353,1354],{},"blocking"," 機能を有効にします（",[160,1357,1358],{},"reqwest = { version = \"0.11.20\", features = [\"blocking\"] }","）",[40,1361,1362,1363,1344,1366,1368],{},"エラー：",[160,1364,1365],{},"failed to resolve: use of undeclared crate or module reqwest",[160,1367,1015],{}," クレートを追加します",[40,1370,1362,1371,1344,1374,1368],{},[160,1372,1373],{},"failed to resolve: use of undeclared crate or module roxmltree",[160,1375,1376],{},"roxmltree",[172,1378,1380],{"className":352,"code":1379,"language":354,"meta":177,"style":177},"vim Config.toml\n\nreqwest = { version = \"0.11.20\", features = [\"blocking\"] }\n",[160,1381,1382,1390,1394],{"__ignoreMap":177},[181,1383,1384,1387],{"class":183,"line":184},[181,1385,1386],{"class":361},"vim",[181,1388,1389],{"class":365}," Config.toml\n",[181,1391,1392],{"class":183,"line":191},[181,1393,188],{"emptyLinePlaceholder":187},[181,1395,1396,1398,1401,1404,1407,1409,1412,1415,1417,1420,1423],{"class":183,"line":198},[181,1397,1015],{"class":361},[181,1399,1400],{"class":365}," =",[181,1402,1403],{"class":365}," {",[181,1405,1406],{"class":365}," version",[181,1408,1400],{"class":365},[181,1410,1411],{"class":365}," \"0.11.20\",",[181,1413,1414],{"class":365}," features",[181,1416,1400],{"class":365},[181,1418,1419],{"class":481}," [",[181,1421,1422],{"class":365},"\"blocking\"",[181,1424,1425],{"class":481},"] }\n",[172,1427,1429],{"className":352,"code":1428,"language":354,"meta":177,"style":177},"cargo add reqwest\ncargo add roxmltree\n",[160,1430,1431,1440],{"__ignoreMap":177},[181,1432,1433,1435,1437],{"class":183,"line":184},[181,1434,383],{"class":361},[181,1436,402],{"class":365},[181,1438,1439],{"class":365}," reqwest\n",[181,1441,1442,1444,1446],{"class":183,"line":191},[181,1443,383],{"class":361},[181,1445,402],{"class":365},[181,1447,1448],{"class":365}," roxmltree\n",[12,1450,1451,1453,1454,1457],{},[167,1452,169],{},"：エラーメッセージの文字列を ",[160,1455,1456],{},"Rust \u003Cerror message>"," としてブラウザで検索し、欠落しているクレートが利用可能であるかどうか確認しましょう。通常、検索結果に「crates.io」が表示され、そこから不足している依存関係を追加できます。",[12,1459,1460,1461,1464],{},"ビルドが成功したら、",[160,1462,1463],{},"cargo run"," でコードを実行し、Hacker NewsのRSSフィードの出力を確認します。",[12,1466,1467,231],{},[227,1468],{"alt":1469,"src":1470},"VS Codeのターミナルでcargo runを実行して、Hacker NewsのXMLフィードを取得","https://res.cloudinary.com/about-gitlab-com/image/upload/v1782398629/blog/Content%20Images/learn-rust-with-ai-code-suggestions-advanced-programming/vs_code_terminal_fetch_rss_feed_output_hacker_news.png",[12,1472,1473],{},"XML本文を人間が読める形式に解析するにはどうすればいいでしょうか？次のセクションでは、既存の解決策とRustのクレートがどのように機能するかを説明します。",[137,1475,1476],{"id":1476},"クレート",[12,1478,1479],{},"RSSフィードは共通のプロトコルと仕様に基づいており、XMLを解析して下位のオブジェクト構造を理解するのは、例えば車輪のように、すでに存在しているものを再び深く掘り下げて再発明するかのようです。。こういったタスクに対するおすすめのアプローチは、過去に同じ問題に直面した人がいないか、また、その問題を解決するためのコードがすでに作られていないかを調べることです。",[12,1481,1482,1483,1489,1490,1063,1492,1495,1496,1499],{},"Rustでの再利用可能なライブラリコードは ",[16,1484,1487],{"href":1485,"rel":1486},"https://doc.rust-lang.org/rust-by-example/crates.html",[],[160,1488,265],{},"と呼ばれる単位で整理され、パッケージで提供されます。これらはcrates.ioのパッケージレジストリで利用可能です。これらの依存関係をプロジェクトに追加するには、",[160,1491,1347],{},[160,1493,1494],{},"[dependencies]"," セクションを編集するか、",[160,1497,1498],{},"cargo add \u003Cname>"," コマンドを使用します。",[12,1501,1502,1503,1508],{},"リーダーアプリケーションでは、",[16,1504,1507],{"href":1505,"rel":1506},"https://crates.io/crates/feed-rs",[],"feed-rs クレート","を使用したいため、新しいターミナルを開き、次のコマンドを実行してください。",[172,1510,1512],{"className":352,"code":1511,"language":354,"meta":177,"style":177},"cargo add feed-rs\n",[160,1513,1514],{"__ignoreMap":177},[181,1515,1516,1518,1520],{"class":183,"line":184},[181,1517,383],{"class":361},[181,1519,402],{"class":365},[181,1521,1522],{"class":365}," feed-rs\n",[12,1524,1525],{},[227,1526],{"alt":1527,"src":1528},"VS Codeのターミナル：クレートを追加し、Config.tomlで確認","https://res.cloudinary.com/about-gitlab-com/image/upload/v1782398627/blog/Content%20Images/learn-rust-with-ai-code-suggestions-advanced-programming/vs_code_rust_crate_add_feed-rs_explained.png",[154,1530,77],{"id":1531},"feed-rsxmlフィードの解析",[12,1533,1534,1537,1538,1351,1541,1544,1545,1547],{},[160,1535,1536],{},"src/feed_reader.rs"," に移動し、XML本文を解析する部分に対して修正を加えます。コード提案は、",[160,1539,1540],{},"feed-rs",[160,1542,1543],{},"parser::parse"," 関数をどのように呼び出すか理解していますが、ひとつだけ特別な点があります。",[160,1546,1540],{}," は文字列をrawバイトとして入力し、自らエンコーディングを判断します。ただし、コメントに指示を追加することで、期待の結果を得ることは可能です。",[172,1549,1551],{"className":174,"code":1550,"language":176,"meta":177,"style":177},"\n            // Parse XML body with feed_rs parser, input in bytes\n            let parsed_body = feed_rs::parser::parse(body.as_bytes()).unwrap();\n\n",[160,1552,1553,1557,1562],{"__ignoreMap":177},[181,1554,1555],{"class":183,"line":184},[181,1556,188],{"emptyLinePlaceholder":187},[181,1558,1559],{"class":183,"line":191},[181,1560,1561],{"class":194},"            // Parse XML body with feed_rs parser, input in bytes\n",[181,1563,1564,1567,1570,1573,1576,1578,1581,1583,1586,1589,1592,1595,1598,1600,1603],{"class":183,"line":198},[181,1565,1566],{"class":474},"            let",[181,1568,1569],{"class":481}," parsed_body ",[181,1571,1572],{"class":474},"=",[181,1574,1575],{"class":361}," feed_rs",[181,1577,554],{"class":474},[181,1579,1580],{"class":361},"parser",[181,1582,554],{"class":474},[181,1584,1585],{"class":361},"parse",[181,1587,1588],{"class":481},"(body",[181,1590,1591],{"class":474},".",[181,1593,1594],{"class":361},"as_bytes",[181,1596,1597],{"class":481},"())",[181,1599,1591],{"class":474},[181,1601,1602],{"class":361},"unwrap",[181,1604,1605],{"class":481},"();\n",[12,1607,1608,231],{},[227,1609],{"alt":1610,"src":1611},"コード提案：get_feeds() 関数を含む公開モジュール、ステップ5：XMLパーサーをfeed-rsに変更","https://res.cloudinary.com/about-gitlab-com/image/upload/v1782398623/blog/Content%20Images/learn-rust-with-ai-code-suggestions-advanced-programming/code_suggestions_rust_module_function_05_use_feed_rs_to_parse.png",[12,1613,1614,1616,1617,1619],{},[160,1615,1540],{}," を使用するメリットは即座に可視化できるものでなく、",[160,1618,1463],{}," で出力を確認するとその効果が明らかになります。すべてのキーと値がそれぞれのRustオブジェクト型にマッピングされ、さらに高度な処理に利用できるようになります。",[12,1621,1622,231],{},[227,1623],{"alt":1624,"src":1625},"VS Codeのターミナル、cargo runを実行してHacker NewsのXMLフィードを取得","https://res.cloudinary.com/about-gitlab-com/image/upload/v1782398629/blog/Content%20Images/learn-rust-with-ai-code-suggestions-advanced-programming/vs_code_terminal_fetch_rss_feed_output_hacker_news_feed_rs.png",[137,1627,1629],{"id":1628},"ランタイム設定プログラム引数","ランタイム設定：プログラム引数",[12,1631,1632],{},"ここまで、コンパイル時にバイナリに埋め込まれ、ハードコードされたRSSフィードの値を使用してプログラムを実行してきました。次のステップでは、実行時にRSSフィードを設定できるようにします。",[12,1634,1635,1636,1641,1642,1647,1648,1653,1654,1659],{},"Rustでは、標準miscライブラリに",[16,1637,1640],{"href":1638,"rel":1639},"https://doc.rust-lang.org/rust-by-example/std_misc/arg.html",[],"プログラム引数","を処理するための機能が用意されています。",[16,1643,1646],{"href":1644,"rel":1645},"https://doc.rust-lang.org/rust-by-example/std_misc/arg/matching.html",[],"プログラム引数を解析","することで、高度なプログラム引数パーサー（たとえば",[16,1649,1652],{"href":1650,"rel":1651},"https://docs.rs/clap/latest/clap/",[],"clap","クレート）を使用したり、プログラムパラメータを構成ファイルやフォーマット（",[16,1655,1658],{"href":1656,"rel":1657},"https://toml.io/en/",[],"TOML","やYAML）に移したりするよりも、簡単かつ効率的に学習を進めることができます。実際にいくつかの方法を試した結果、学習効果を最大限に高めるには、この方法が最適であると判断しましたが、唯一の方法ではありません。他の方法でRSSフィードの設定を試してみる価値もあります。",[12,1661,1662,1663,1666,1667,1670,1671,1673,1674,1677,1678,1681],{},"単純な解決策としては、コマンドパラメータを ",[160,1664,1665],{},"\"name,url\""," の文字列ペアとして渡してから、",[160,1668,1669],{},","," で分割して名前とURLの値を抽出します。コード提案に、これらの操作を実行して新しい値で ",[160,1672,516],{}," ハッシュマップを拡張するようコメントで指示します。変数が変更可能でない可能性があるため、",[160,1675,1676],{},"let rss_feeds"," を ",[160,1679,1680],{},"let mut rss_feeds"," に変更する必要がある点にご注意ください。",[12,1683,1684,1686,1687,1689,1690,1692],{},[160,1685,451],{}," に移動し、",[160,1688,516],{}," 変数の後に次のコードを ",[160,1691,455],{}," 関数の追加します。まずはコメントでプログラム引数を定義し、提案されたコードスニペットを確認します。",[172,1694,1696],{"className":174,"code":1695,"language":176,"meta":177,"style":177},"\n    // Program args, format \"name,url\"\n    // Split value by , into name, url and add to rss_feeds\n\n",[160,1697,1698,1702,1707],{"__ignoreMap":177},[181,1699,1700],{"class":183,"line":184},[181,1701,188],{"emptyLinePlaceholder":187},[181,1703,1704],{"class":183,"line":191},[181,1705,1706],{"class":194},"    // Program args, format \"name,url\"\n",[181,1708,1709],{"class":183,"line":198},[181,1710,1711],{"class":194},"    // Split value by , into name, url and add to rss_feeds\n",[12,1713,1714,231],{},[227,1715],{"alt":1716,"src":1717},"プログラム引数に関するコード提案、および rss_feeds 変数のために名前とURLの値を分割するコード提案","https://res.cloudinary.com/about-gitlab-com/image/upload/v1782398623/blog/Content%20Images/learn-rust-with-ai-code-suggestions-advanced-programming/code_suggestions_rust_program_args_boring_solution.png",[12,1719,1720],{},"コード全体の例は次のようになります。",[172,1722,1724],{"className":174,"code":1723,"language":176,"meta":177,"style":177},"fn main() {##$_0A$##    // Define RSS feed URLs in the variable rss_feeds##$_0A$##    // Use a HashMap##$_0A$##    // Add Hacker News and TechCrunch##$_0A$##    // Ensure to use String as type##$_0A$##    let mut rss_feeds = HashMap::from([##$_0A$##        (\"Hacker News\".to_string(), \"https://news.ycombinator.com/rss\".to_string()),##$_0A$## (\"TechCrunch\".to_string(), \"https://techcrunch.com/feed/\".to_string()),##$_0A$## ]);##$_0A$####$_0A$##    // Program args, format \"name,url\"##$_0A$##    // Split value by , into name, url and add to rss_feeds##$_0A$##    for arg in std::env::args().skip(1) {##$_0A$##        let mut split = arg.split(\",\");##$_0A$##        let name = split.next().unwrap();##$_0A$##        let url = split.next().unwrap();##$_0A$##        rss_feeds.insert(name.to_string(), url.to_string());##$_0A$##    }##$_0A$####$_0A$##    // Call get_feeds() from feed_reader module##$_0A$## feed_reader::feed_reader::get_feeds(&rss_feeds);##$_0A$##    // Alternative: Imported full path, use short path here.##$_0A$## //get_feeds(&rss_feeds);##$_0A$##}\n",[160,1725,1726],{"__ignoreMap":177},[181,1727,1728,1730,1732,1734,1736,1738,1740,1742,1744,1746,1748,1751,1754,1757,1759,1761],{"class":183,"line":184},[181,1729,475],{"class":474},[181,1731,478],{"class":361},[181,1733,482],{"class":481},[181,1735,485],{"class":474},[181,1737,488],{"class":481},[181,1739,485],{"class":474},[181,1741,493],{"class":481},[181,1743,496],{"class":194},[181,1745,499],{"class":194},[181,1747,502],{"class":194},[181,1749,1750],{"class":194},"    // Ensure to use String as type##$_0A$##    let mut rss_feeds = HashMap::from([##$_0A$##        (\"Hacker News\".to_string(), \"https://news.ycombinator.com/rss\".to_string()),##$_0A$## (\"TechCrunch\".to_string(), \"https://techcrunch.com/feed/\".to_string()),##$_0A$## ]);##$_0A$####$_0A$##",[181,1752,1753],{"class":194},"    // Program args, format \"name,url\"##$_0A$##",[181,1755,1756],{"class":194},"    // Split value by , into name, url and add to rss_feeds##$_0A$##    for arg in std::env::args().skip(1) {##$_0A$##        let mut split = arg.split(\",\");##$_0A$##        let name = split.next().unwrap();##$_0A$##        let url = split.next().unwrap();##$_0A$##        rss_feeds.insert(name.to_string(), url.to_string());##$_0A$##    }##$_0A$####$_0A$##",[181,1758,1308],{"class":194},[181,1760,1311],{"class":194},[181,1762,1314],{"class":194},[12,1764,1765,1766,1768,1769,1772],{},"プログラムの引数を ",[160,1767,1463],{}," コマンドに直接渡すことができます。その際は引数の前に ",[160,1770,1771],{},"--","をつけます。 すべての引数をダブルクォートで囲み、名前の後にカンマを付けてRSSフィードのURLを引数として渡します。引数は空白で区切ります。",[172,1774,1776],{"className":352,"code":1775,"language":354,"meta":177,"style":177},"cargo build\n\ncargo run -- \"GitLab Blog,https://about.gitlab.com/atom.xml\" \"CNCF,https://www.cncf.io/feed/\"\n",[160,1777,1778,1784,1788],{"__ignoreMap":177},[181,1779,1780,1782],{"class":183,"line":184},[181,1781,383],{"class":361},[181,1783,1332],{"class":365},[181,1785,1786],{"class":183,"line":191},[181,1787,188],{"emptyLinePlaceholder":187},[181,1789,1790,1792,1795,1798,1801],{"class":183,"line":198},[181,1791,383],{"class":361},[181,1793,1794],{"class":365}," run",[181,1796,1797],{"class":371}," --",[181,1799,1800],{"class":365}," \"GitLab Blog,https://about.gitlab.com/atom.xml\"",[181,1802,1803],{"class":365}," \"CNCF,https://www.cncf.io/feed/\"\n",[12,1805,1806,231],{},[227,1807],{"alt":1808,"src":1809},"VS Codeターミナル、GitLabブログのRSSフィード出力例","https://res.cloudinary.com/about-gitlab-com/image/upload/v1782398630/blog/Content%20Images/learn-rust-with-ai-code-suggestions-advanced-programming/vs_code_terminal_gitlab_blog_rss_feed_example.png",[154,1811,85],{"id":85},[12,1813,1814,1815,1820],{},"提供されたユーザー入力がプログラムで想定される内容と異なる場合、",[16,1816,1819],{"href":1817,"rel":1818},"https://doc.rust-lang.org/rust-by-example/error.html",[],"エラーを発生","させ、呼び出し元がプログラム引数を修正できるようにする必要があります。たとえば、不正なURL形式が渡された場合、それをランタイムエラーとして処理する必要があります。コード提案に対し、URLが無効な場合はエラーをスローするようコメントで指示します。",[172,1822,1824],{"className":174,"code":1823,"language":176,"meta":177,"style":177},"\n    // Ensure that URL contains a valid format, otherwise throw an error\n\n",[160,1825,1826,1830],{"__ignoreMap":177},[181,1827,1828],{"class":183,"line":184},[181,1829,188],{"emptyLinePlaceholder":187},[181,1831,1832],{"class":183,"line":191},[181,1833,1834],{"class":194},"    // Ensure that URL contains a valid format, otherwise throw an error\n",[12,1836,1837,1838,1841,1842,1845,1846,1849,1850,1855],{},"ひとつの解決策として、",[160,1839,1840],{},"url"," 変数が ",[160,1843,1844],{},"http://"," または ",[160,1847,1848],{},"https://"," で始まっているかを確認し、そうでなければ ",[16,1851,1854],{"href":1852,"rel":1853},"https://doc.rust-lang.org/rust-by-example/std/panic.html",[],"panic! マクロ","を使ってエラーをスローする方法があります。コード全体の例は次のようになります。",[172,1857,1859],{"className":174,"code":1858,"language":176,"meta":177,"style":177},"\n    // Program args, format \"name,url\"\n    // Split value by , into name, url and add to rss_feeds\n    for arg in std::env::args().skip(1) {\n        let mut split = arg.split(\",\");\n        let name = split.next().unwrap();\n        let url = split.next().unwrap();\n\n        // Ensure that URL contains a valid format, otherwise throw an error\n        if !url.starts_with(\"http://\") && !url.starts_with(\"https://\") {\n            panic!(\"Invalid URL format: {}\", url);\n        }\n\n        rss_feeds.insert(name.to_string(), url.to_string());\n    }\n\n",[160,1860,1861,1865,1869,1873,1912,1941,1966,1989,1994,2000,2042,2056,2062,2067,2096],{"__ignoreMap":177},[181,1862,1863],{"class":183,"line":184},[181,1864,188],{"emptyLinePlaceholder":187},[181,1866,1867],{"class":183,"line":191},[181,1868,1706],{"class":194},[181,1870,1871],{"class":183,"line":198},[181,1872,1711],{"class":194},[181,1874,1875,1878,1881,1884,1886,1888,1891,1893,1896,1899,1901,1904,1906,1909],{"class":183,"line":204},[181,1876,1877],{"class":474},"    for",[181,1879,1880],{"class":481}," arg ",[181,1882,1883],{"class":474},"in",[181,1885,551],{"class":361},[181,1887,554],{"class":474},[181,1889,1890],{"class":361},"env",[181,1892,554],{"class":474},[181,1894,1895],{"class":361},"args",[181,1897,1898],{"class":481},"()",[181,1900,1591],{"class":474},[181,1902,1903],{"class":361},"skip",[181,1905,1124],{"class":481},[181,1907,1908],{"class":371},"1",[181,1910,1911],{"class":481},") {\n",[181,1913,1914,1917,1920,1923,1925,1928,1930,1933,1935,1938],{"class":183,"line":210},[181,1915,1916],{"class":474},"        let",[181,1918,1919],{"class":474}," mut",[181,1921,1922],{"class":481}," split ",[181,1924,1572],{"class":474},[181,1926,1927],{"class":481}," arg",[181,1929,1591],{"class":474},[181,1931,1932],{"class":361},"split",[181,1934,1124],{"class":481},[181,1936,1937],{"class":365},"\",\"",[181,1939,1940],{"class":481},");\n",[181,1942,1943,1945,1948,1950,1953,1955,1958,1960,1962,1964],{"class":183,"line":393},[181,1944,1916],{"class":474},[181,1946,1947],{"class":481}," name ",[181,1949,1572],{"class":474},[181,1951,1952],{"class":481}," split",[181,1954,1591],{"class":474},[181,1956,1957],{"class":361},"next",[181,1959,1898],{"class":481},[181,1961,1591],{"class":474},[181,1963,1602],{"class":361},[181,1965,1605],{"class":481},[181,1967,1968,1970,1973,1975,1977,1979,1981,1983,1985,1987],{"class":183,"line":411},[181,1969,1916],{"class":474},[181,1971,1972],{"class":481}," url ",[181,1974,1572],{"class":474},[181,1976,1952],{"class":481},[181,1978,1591],{"class":474},[181,1980,1957],{"class":361},[181,1982,1898],{"class":481},[181,1984,1591],{"class":474},[181,1986,1602],{"class":361},[181,1988,1605],{"class":481},[181,1990,1992],{"class":183,"line":1991},8,[181,1993,188],{"emptyLinePlaceholder":187},[181,1995,1997],{"class":183,"line":1996},9,[181,1998,1999],{"class":194},"        // Ensure that URL contains a valid format, otherwise throw an error\n",[181,2001,2003,2006,2009,2011,2013,2016,2018,2021,2024,2027,2029,2031,2033,2035,2037,2040],{"class":183,"line":2002},10,[181,2004,2005],{"class":474},"        if",[181,2007,2008],{"class":474}," !",[181,2010,1840],{"class":481},[181,2012,1591],{"class":474},[181,2014,2015],{"class":361},"starts_with",[181,2017,1124],{"class":481},[181,2019,2020],{"class":365},"\"http://\"",[181,2022,2023],{"class":481},") ",[181,2025,2026],{"class":474},"&&",[181,2028,2008],{"class":474},[181,2030,1840],{"class":481},[181,2032,1591],{"class":474},[181,2034,2015],{"class":361},[181,2036,1124],{"class":481},[181,2038,2039],{"class":365},"\"https://\"",[181,2041,1911],{"class":481},[181,2043,2045,2048,2050,2053],{"class":183,"line":2044},11,[181,2046,2047],{"class":361},"            panic!",[181,2049,1124],{"class":481},[181,2051,2052],{"class":365},"\"Invalid URL format: {}\"",[181,2054,2055],{"class":481},", url);\n",[181,2057,2059],{"class":183,"line":2058},12,[181,2060,2061],{"class":481},"        }\n",[181,2063,2065],{"class":183,"line":2064},13,[181,2066,188],{"emptyLinePlaceholder":187},[181,2068,2070,2073,2075,2078,2081,2083,2086,2089,2091,2093],{"class":183,"line":2069},14,[181,2071,2072],{"class":481},"        rss_feeds",[181,2074,1591],{"class":474},[181,2076,2077],{"class":361},"insert",[181,2079,2080],{"class":481},"(name",[181,2082,1591],{"class":474},[181,2084,2085],{"class":361},"to_string",[181,2087,2088],{"class":481},"(), url",[181,2090,1591],{"class":474},[181,2092,2085],{"class":361},[181,2094,2095],{"class":481},"());\n",[181,2097,2099],{"class":183,"line":2098},15,[181,2100,2101],{"class":481},"    }\n",[12,2103,2104,2105,2107,2108,2111,2112,2115],{},"任意のURL文字列から ",[160,2106,757],{}," を削除してエラーハンドリングをテストします。",[160,2109,2110],{},"RUST_BACKTRACE=full"," 環境変数を追加すると、",[160,2113,2114],{},"panic()"," 呼び出しが発生した際に詳細な出力を取得できます。",[172,2117,2119],{"className":352,"code":2118,"language":354,"meta":177,"style":177},"RUST_BACKTRACE=full cargo run -- \"GitLab Blog,https://about.gitlab.com/atom.xml\" \"CNCF,https//www.cncf.io/feed/\"\n",[160,2120,2121],{"__ignoreMap":177},[181,2122,2123,2126,2128,2131,2134,2136,2138,2140],{"class":183,"line":184},[181,2124,2125],{"class":481},"RUST_BACKTRACE",[181,2127,1572],{"class":474},[181,2129,2130],{"class":365},"full",[181,2132,2133],{"class":361}," cargo",[181,2135,1794],{"class":365},[181,2137,1797],{"class":371},[181,2139,1800],{"class":365},[181,2141,2142],{"class":365}," \"CNCF,https//www.cncf.io/feed/\"\n",[12,2144,2145,231],{},[227,2146],{"alt":2147,"src":2148},"間違ったURL形式によるパニックエラーのバックトレースが表示されたVS Codeターミナル","https://res.cloudinary.com/about-gitlab-com/image/upload/v1782398630/blog/Content%20Images/learn-rust-with-ai-code-suggestions-advanced-programming/vs_code_terminal_url_format_error_panic_backtrace.png",[137,2150,88],{"id":88},[12,2152,2153],{},"フィードデータを保存する単純な解決策は、解析されたデータを新しいファイルに書き出すことです。コード提案に、RSSフィードの名前と現在のISO日付を含むパターンでファイルを保存するよう指示します。",[172,2155,2157],{"className":174,"code":2156,"language":176,"meta":177,"style":177},"\n    // Parse XML body with feed_rs parser, input in bytes\n    let parsed_body = feed_rs::parser::parse(body.as_bytes()).unwrap();\n\n    // Print the result\n    println!(\"{:#?}\", parsed_body);\n\n    // Dump the parsed body to a file, as name-current-iso-date.xml\n    let now = chrono::offset::Local::now();\n    let filename = format!(\"{}-{}.xml\", name, now.format(\"%Y-%m-%d\"));\n    let mut file = std::fs::File::create(filename).unwrap();\n    file.write_all(body.as_bytes()).unwrap();\n\n",[160,2158,2159,2163,2168,2201,2205,2210,2223,2227,2232,2261,2294,2331],{"__ignoreMap":177},[181,2160,2161],{"class":183,"line":184},[181,2162,188],{"emptyLinePlaceholder":187},[181,2164,2165],{"class":183,"line":191},[181,2166,2167],{"class":194},"    // Parse XML body with feed_rs parser, input in bytes\n",[181,2169,2170,2173,2175,2177,2179,2181,2183,2185,2187,2189,2191,2193,2195,2197,2199],{"class":183,"line":198},[181,2171,2172],{"class":474},"    let",[181,2174,1569],{"class":481},[181,2176,1572],{"class":474},[181,2178,1575],{"class":361},[181,2180,554],{"class":474},[181,2182,1580],{"class":361},[181,2184,554],{"class":474},[181,2186,1585],{"class":361},[181,2188,1588],{"class":481},[181,2190,1591],{"class":474},[181,2192,1594],{"class":361},[181,2194,1597],{"class":481},[181,2196,1591],{"class":474},[181,2198,1602],{"class":361},[181,2200,1605],{"class":481},[181,2202,2203],{"class":183,"line":204},[181,2204,188],{"emptyLinePlaceholder":187},[181,2206,2207],{"class":183,"line":210},[181,2208,2209],{"class":194},"    // Print the result\n",[181,2211,2212,2215,2217,2220],{"class":183,"line":393},[181,2213,2214],{"class":361},"    println!",[181,2216,1124],{"class":481},[181,2218,2219],{"class":365},"\"{:#?}\"",[181,2221,2222],{"class":481},", parsed_body);\n",[181,2224,2225],{"class":183,"line":411},[181,2226,188],{"emptyLinePlaceholder":187},[181,2228,2229],{"class":183,"line":1991},[181,2230,2231],{"class":194},"    // Dump the parsed body to a file, as name-current-iso-date.xml\n",[181,2233,2234,2236,2239,2241,2244,2246,2249,2251,2254,2256,2259],{"class":183,"line":1996},[181,2235,2172],{"class":474},[181,2237,2238],{"class":481}," now ",[181,2240,1572],{"class":474},[181,2242,2243],{"class":361}," chrono",[181,2245,554],{"class":474},[181,2247,2248],{"class":361},"offset",[181,2250,554],{"class":474},[181,2252,2253],{"class":361},"Local",[181,2255,554],{"class":474},[181,2257,2258],{"class":361},"now",[181,2260,1605],{"class":481},[181,2262,2263,2265,2268,2270,2273,2275,2278,2281,2283,2286,2288,2291],{"class":183,"line":2002},[181,2264,2172],{"class":474},[181,2266,2267],{"class":481}," filename ",[181,2269,1572],{"class":474},[181,2271,2272],{"class":361}," format!",[181,2274,1124],{"class":481},[181,2276,2277],{"class":365},"\"{}-{}.xml\"",[181,2279,2280],{"class":481},", name, now",[181,2282,1591],{"class":474},[181,2284,2285],{"class":361},"format",[181,2287,1124],{"class":481},[181,2289,2290],{"class":365},"\"%Y-%m-%d\"",[181,2292,2293],{"class":481},"));\n",[181,2295,2296,2298,2300,2303,2305,2307,2309,2312,2314,2317,2319,2322,2325,2327,2329],{"class":183,"line":2044},[181,2297,2172],{"class":474},[181,2299,1919],{"class":474},[181,2301,2302],{"class":481}," file ",[181,2304,1572],{"class":474},[181,2306,551],{"class":361},[181,2308,554],{"class":474},[181,2310,2311],{"class":361},"fs",[181,2313,554],{"class":474},[181,2315,2316],{"class":361},"File",[181,2318,554],{"class":474},[181,2320,2321],{"class":361},"create",[181,2323,2324],{"class":481},"(filename)",[181,2326,1591],{"class":474},[181,2328,1602],{"class":361},[181,2330,1605],{"class":481},[181,2332,2333,2336,2338,2341,2343,2345,2347,2349,2351,2353],{"class":183,"line":2058},[181,2334,2335],{"class":481},"    file",[181,2337,1591],{"class":474},[181,2339,2340],{"class":361},"write_all",[181,2342,1588],{"class":481},[181,2344,1591],{"class":474},[181,2346,1594],{"class":361},[181,2348,1597],{"class":481},[181,2350,1591],{"class":474},[181,2352,1602],{"class":361},[181,2354,1605],{"class":481},[12,2356,2357,2358,2363,2364,2367,2368,2370,2371,2373],{},"この処理の一例として、",[16,2359,2362],{"href":2360,"rel":2361},"https://crates.io/crates/chrono",[],"chronoクレート","を使用する方法があります。",[160,2365,2366],{},"cargo add chrono"," を実行して追加し、その後 ",[160,2369,609],{}," と ",[160,2372,1463],{}," を再度実行します。",[12,2375,2376,2377,2379,2380,2383],{},"ファイルは ",[160,2378,1463],{}," が実行されたディレクトリに保存されます。バイナリを ",[160,2381,2382],{},"target/debug/"," ディレクトリで直接実行している場合、すべてのファイルはそのディレクトリにダンプされます。",[12,2385,2386],{},[227,2387],{"alt":2388,"src":2389},"CNCFのRSSフィード内容を含むファイルがディスクに保存された状態のVS Code","https://res.cloudinary.com/about-gitlab-com/image/upload/v1782398626/blog/Content%20Images/learn-rust-with-ai-code-suggestions-advanced-programming/vs_code_cncf_rss_feed_saved_on_disk.png",[137,2391,2392],{"id":2392},"最適化",[12,2394,2395,2397],{},[160,2396,516],{}," 変数内のエントリは逐次実行されています。もし100件以上のURLがリストに設定されている場合、データの取得と処理にはかなりの時間がかかるでしょう。複数のフェッチリクエストを並行して実行できたらどうでしょうか？",[154,2399,96],{"id":96},[12,2401,2402,2403,2408],{},"Rustでは、",[16,2404,2407],{"href":2405,"rel":2406},"https://doc.rust-lang.org/book/ch16-01-threads.html",[],"スレッド","を使用した非同期実行が可能です。",[12,2410,2411,2412,2415,2416,2418],{},"最も簡単な解決策は、各RSSフィードURLごとにスレッドを生成することです。最適化戦略については後のセクションで説明します。並行実行を開始する前に、 ",[160,2413,2414],{},"time"," コマンドの前に",[160,2417,1463],{}," をつけて、逐次実行コードの実行時間を測定しましょう。",[172,2420,2423],{"className":2421,"code":2422,"language":1056,"meta":177},[1054],"time cargo run -- \"GitLab Blog,https://about.gitlab.com/atom.xml\" \"CNCF,https://www.cncf.io/feed/\"\n\n0.21s user 0.08s system 10% cpu 2.898 total\n",[160,2424,2422],{"__ignoreMap":177},[12,2426,2427,2428,2431],{},"なお、この演習では、手動のコーディング作業が多くなる場合があります。並列実行の影響をより効果的に比較するには、逐次実行の動作状態を新しいGitコミットとブランチ ",[160,2429,2430],{},"sequential-exec"," に保存してください。",[172,2433,2435],{"className":352,"code":2434,"language":354,"meta":177,"style":177},"git commit -avm \"Sequential execution working\"\ngit checkout -b sequential-exec\ngit push -u origin sequential-exec\n\ngit checkout main\n",[160,2436,2437,2450,2463,2476,2480],{"__ignoreMap":177},[181,2438,2439,2441,2444,2447],{"class":183,"line":184},[181,2440,396],{"class":361},[181,2442,2443],{"class":365}," commit",[181,2445,2446],{"class":371}," -avm",[181,2448,2449],{"class":365}," \"Sequential execution working\"\n",[181,2451,2452,2454,2457,2460],{"class":183,"line":191},[181,2453,396],{"class":361},[181,2455,2456],{"class":365}," checkout",[181,2458,2459],{"class":371}," -b",[181,2461,2462],{"class":365}," sequential-exec\n",[181,2464,2465,2467,2469,2472,2474],{"class":183,"line":198},[181,2466,396],{"class":361},[181,2468,416],{"class":365},[181,2470,2471],{"class":371}," -u",[181,2473,405],{"class":365},[181,2475,2462],{"class":365},[181,2477,2478],{"class":183,"line":204},[181,2479,188],{"emptyLinePlaceholder":187},[181,2481,2482,2484,2486],{"class":183,"line":210},[181,2483,396],{"class":361},[181,2485,2456],{"class":365},[181,2487,424],{"class":365},[154,2489,99],{"id":99},[12,2491,2492,2494,2495,2497],{},[160,2493,1536],{}," を開き、",[160,2496,637],{}," 関数をリファクタリングします。まず、現在の状態をGitコミットで保存し、その後、関数のスコープ内の内容を削除します。次に、コード提案への指示と以下のコードコメントを入力します。",[282,2499,2500,2506],{},[40,2501,2502,2505],{},[160,2503,2504],{},"// Store threads in vector","：スレッドのハンドルをベクターに格納し、関数呼び出しの最後にスレッドが終了するまで待機できるようにします。",[40,2507,2508,2511],{},[160,2509,2510],{},"// Loop over rss_feeds and spawn threads","：すべてのRSSフィードを反復処理するためのコードを作成し、新しいスレッドを作成します。",[12,2513,2514,2517,2518,2520,2521,2523],{},[160,2515,2516],{},"thread"," モジュールと ",[160,2519,2414],{}," モジュールを扱うには、次の ",[160,2522,548],{}," 文を追加します。",[172,2525,2527],{"className":174,"code":2526,"language":176,"meta":177,"style":177},"\n    use std::thread;\n    use std::time::Duration;\n\n",[160,2528,2529,2533,2545],{"__ignoreMap":177},[181,2530,2531],{"class":183,"line":184},[181,2532,188],{"emptyLinePlaceholder":187},[181,2534,2535,2538,2540,2542],{"class":183,"line":191},[181,2536,2537],{"class":474},"    use",[181,2539,551],{"class":361},[181,2541,554],{"class":474},[181,2543,2544],{"class":481},"thread;\n",[181,2546,2547,2549,2551,2553,2555,2557,2560],{"class":183,"line":198},[181,2548,2537],{"class":474},[181,2550,551],{"class":361},[181,2552,554],{"class":474},[181,2554,2414],{"class":361},[181,2556,554],{"class":474},[181,2558,2559],{"class":361},"Duration",[181,2561,564],{"class":481},[12,2563,2564,2565,2568],{},"その後、forループを閉じるまでコードを書き進めます。コード提案は、自動的にスレッドハンドルを ",[160,2566,2567],{},"threads"," ベクター変数に追加し、関数の最後でスレッドを結合（join）するよう提案します。",[172,2570,2572],{"className":174,"code":2571,"language":176,"meta":177,"style":177},"\n    pub fn get_feeds(rss_feeds: &HashMap\u003CString, String>) {\n\n        // Store threads in vector\n        let mut threads: Vec\u003Cthread::JoinHandle\u003C()>> = Vec::new();\n\n        // Loop over rss_feeds and spawn threads\n        for (name, url) in rss_feeds {\n            let thread_name = name.clone();\n            let thread_url = url.clone();\n            let thread = thread::spawn(move || {\n\n            });\n            threads.push(thread);\n        }\n\n        // Join threads\n        for thread in threads {\n            thread.join().unwrap();\n        }\n    }\n\n",[160,2573,2574,2578,2606,2610,2615,2651,2655,2660,2673,2692,2710,2738,2742,2747,2760,2764,2769,2775,2787,2806,2811],{"__ignoreMap":177},[181,2575,2576],{"class":183,"line":184},[181,2577,188],{"emptyLinePlaceholder":187},[181,2579,2580,2583,2585,2587,2589,2591,2593,2595,2597,2599,2601,2603],{"class":183,"line":191},[181,2581,2582],{"class":474},"    pub",[181,2584,748],{"class":474},[181,2586,751],{"class":361},[181,2588,754],{"class":481},[181,2590,757],{"class":474},[181,2592,760],{"class":474},[181,2594,463],{"class":361},[181,2596,765],{"class":481},[181,2598,768],{"class":361},[181,2600,771],{"class":481},[181,2602,768],{"class":361},[181,2604,2605],{"class":481},">) {\n",[181,2607,2608],{"class":183,"line":198},[181,2609,188],{"emptyLinePlaceholder":187},[181,2611,2612],{"class":183,"line":204},[181,2613,2614],{"class":194},"        // Store threads in vector\n",[181,2616,2617,2619,2621,2624,2626,2629,2632,2634,2637,2640,2642,2644,2646,2649],{"class":183,"line":210},[181,2618,1916],{"class":474},[181,2620,1919],{"class":474},[181,2622,2623],{"class":481}," threads",[181,2625,757],{"class":474},[181,2627,2628],{"class":361}," Vec",[181,2630,2631],{"class":481},"\u003Cthread",[181,2633,554],{"class":474},[181,2635,2636],{"class":361},"JoinHandle",[181,2638,2639],{"class":481},"\u003C()>> ",[181,2641,1572],{"class":474},[181,2643,2628],{"class":361},[181,2645,554],{"class":474},[181,2647,2648],{"class":361},"new",[181,2650,1605],{"class":481},[181,2652,2653],{"class":183,"line":393},[181,2654,188],{"emptyLinePlaceholder":187},[181,2656,2657],{"class":183,"line":411},[181,2658,2659],{"class":194},"        // Loop over rss_feeds and spawn threads\n",[181,2661,2662,2665,2668,2670],{"class":183,"line":1991},[181,2663,2664],{"class":474},"        for",[181,2666,2667],{"class":481}," (name, url) ",[181,2669,1883],{"class":474},[181,2671,2672],{"class":481}," rss_feeds {\n",[181,2674,2675,2677,2680,2682,2685,2687,2690],{"class":183,"line":1996},[181,2676,1566],{"class":474},[181,2678,2679],{"class":481}," thread_name ",[181,2681,1572],{"class":474},[181,2683,2684],{"class":481}," name",[181,2686,1591],{"class":474},[181,2688,2689],{"class":361},"clone",[181,2691,1605],{"class":481},[181,2693,2694,2696,2699,2701,2704,2706,2708],{"class":183,"line":2002},[181,2695,1566],{"class":474},[181,2697,2698],{"class":481}," thread_url ",[181,2700,1572],{"class":474},[181,2702,2703],{"class":481}," url",[181,2705,1591],{"class":474},[181,2707,2689],{"class":361},[181,2709,1605],{"class":481},[181,2711,2712,2714,2717,2719,2722,2724,2727,2729,2732,2735],{"class":183,"line":2044},[181,2713,1566],{"class":474},[181,2715,2716],{"class":481}," thread ",[181,2718,1572],{"class":474},[181,2720,2721],{"class":361}," thread",[181,2723,554],{"class":474},[181,2725,2726],{"class":361},"spawn",[181,2728,1124],{"class":481},[181,2730,2731],{"class":474},"move",[181,2733,2734],{"class":474}," ||",[181,2736,2737],{"class":481}," {\n",[181,2739,2740],{"class":183,"line":2058},[181,2741,188],{"emptyLinePlaceholder":187},[181,2743,2744],{"class":183,"line":2064},[181,2745,2746],{"class":481},"            });\n",[181,2748,2749,2752,2754,2757],{"class":183,"line":2069},[181,2750,2751],{"class":481},"            threads",[181,2753,1591],{"class":474},[181,2755,2756],{"class":361},"push",[181,2758,2759],{"class":481},"(thread);\n",[181,2761,2762],{"class":183,"line":2098},[181,2763,2061],{"class":481},[181,2765,2767],{"class":183,"line":2766},16,[181,2768,188],{"emptyLinePlaceholder":187},[181,2770,2772],{"class":183,"line":2771},17,[181,2773,2774],{"class":194},"        // Join threads\n",[181,2776,2778,2780,2782,2784],{"class":183,"line":2777},18,[181,2779,2664],{"class":474},[181,2781,2716],{"class":481},[181,2783,1883],{"class":474},[181,2785,2786],{"class":481}," threads {\n",[181,2788,2790,2793,2795,2798,2800,2802,2804],{"class":183,"line":2789},19,[181,2791,2792],{"class":481},"            thread",[181,2794,1591],{"class":474},[181,2796,2797],{"class":361},"join",[181,2799,1898],{"class":481},[181,2801,1591],{"class":474},[181,2803,1602],{"class":361},[181,2805,1605],{"class":481},[181,2807,2809],{"class":183,"line":2808},20,[181,2810,2061],{"class":481},[181,2812,2814],{"class":183,"line":2813},21,[181,2815,2101],{"class":481},[12,2817,2818,2819,2821],{},"次に、",[160,2820,2516],{}," クレートを追加し、もう一度コードをビルドし実行します。",[172,2823,2825],{"className":352,"code":2824,"language":354,"meta":177,"style":177},"cargo add thread\n\ncargo build\n\ncargo run -- \"GitLab Blog,https://about.gitlab.com/atom.xml\" \"CNCF,https://www.cncf.io/feed/\"\n",[160,2826,2827,2836,2840,2846,2850],{"__ignoreMap":177},[181,2828,2829,2831,2833],{"class":183,"line":184},[181,2830,383],{"class":361},[181,2832,402],{"class":365},[181,2834,2835],{"class":365}," thread\n",[181,2837,2838],{"class":183,"line":191},[181,2839,188],{"emptyLinePlaceholder":187},[181,2841,2842,2844],{"class":183,"line":198},[181,2843,383],{"class":361},[181,2845,1332],{"class":365},[181,2847,2848],{"class":183,"line":204},[181,2849,188],{"emptyLinePlaceholder":187},[181,2851,2852,2854,2856,2858,2860],{"class":183,"line":210},[181,2853,383],{"class":361},[181,2855,1794],{"class":365},[181,2857,1797],{"class":371},[181,2859,1800],{"class":365},[181,2861,1803],{"class":365},[12,2863,2864],{},"この段階では、データの処理や出力は行われていません。次のステップに移る前に、ここで新たに導入されたキーワードについて解説します。",[154,2866,102],{"id":2867},"関数スコープスレッドクロージャ",[12,2869,2870,2871,2874,2875,2880],{},"提案されるコードには新しいキーワードやデザインパターンが含まれることもあるため、これらについて理解しておくことが重要になります。スレッドハンドルは ",[160,2872,2873],{},"thread::JoinHandle"," という型で、スレッドが終わるのを待機するために使用します（",[16,2876,2879],{"href":2877,"rel":2878},"https://doc.rust-lang.org/book/ch16-01-threads.html#waiting-for-all-threads-to-finish-using-join-handles",[],"join()","メソッドを使います）。",[12,2882,2883,2886,2887,2892,2893,2896,2897,2904],{},[160,2884,2885],{},"thread::spawn()"," は新しいスレッドを生成し、このスレッド内では、関数オブジェクトを渡すことができます。この場合、",[16,2888,2891],{"href":2889,"rel":2890},"https://doc.rust-lang.org/book/ch13-01-closures.html",[],"クロージャ","式が無名関数として渡されます。また、クロージャ入力は ",[160,2894,2895],{},"||"," 構文を使用して渡されますが、この際には",[16,2898,2901,2903],{"href":2899,"rel":2900},"https://doc.rust-lang.org/book/ch16-01-threads.html#using-move-closures-with-threads",[],[160,2902,2731],{}," クロージャ","が関数スコープの変数をスレッドスコープに移動します。これにより、どの変数を新しい関数やクロージャスコープに渡すかを手動で指定する必要がなくなります。",[12,2906,2907,2908,2910,2911,2913,2914,2916],{},"ただし、これには制限があります。",[160,2909,516],{}," は参照 ",[160,2912,1127],{}," で、",[160,2915,637],{}," 関数の呼び出し元からパラメータとして渡されています。この変数は関数スコープ内でのみ有効です。このエラーを引き起こすには、次のコードスニペットを使用します。",[172,2918,2920],{"className":174,"code":2919,"language":176,"meta":177,"style":177},"pub fn get_feeds(rss_feeds: &HashMap\u003CString, String>) {##$_0A$####$_0A$## // Store threads in vector##$_0A$##    let mut threads: Vec\u003Cthread::JoinHandle\u003C()>> = Vec::new();##$_0A$####$_0A$##    // Loop over rss_feeds and spawn threads##$_0A$##    for (key, value) in rss_feeds {##$_0A$##        let thread = thread::spawn(move || {##$_0A$## println!(\"{}\", key);##$_0A$##        });##$_0A$##    }##$_0A$##}\n",[160,2921,2922],{"__ignoreMap":177},[181,2923,2924,2926,2928,2930,2932,2934,2936,2938,2940,2942,2944,2946,2948,2950,2952,2954,2956,2958,2960,2962,2965,2968],{"class":183,"line":184},[181,2925,694],{"class":474},[181,2927,748],{"class":474},[181,2929,751],{"class":361},[181,2931,754],{"class":481},[181,2933,757],{"class":474},[181,2935,760],{"class":474},[181,2937,463],{"class":361},[181,2939,765],{"class":481},[181,2941,768],{"class":361},[181,2943,771],{"class":481},[181,2945,768],{"class":361},[181,2947,776],{"class":481},[181,2949,485],{"class":474},[181,2951,488],{"class":481},[181,2953,485],{"class":474},[181,2955,735],{"class":481},[181,2957,485],{"class":474},[181,2959,488],{"class":481},[181,2961,485],{"class":474},[181,2963,2964],{"class":481},"## ",[181,2966,2967],{"class":194},"// Store threads in vector##$_0A$##    let mut threads: Vec\u003Cthread::JoinHandle\u003C()>> = Vec::new();##$_0A$####$_0A$##",[181,2969,2970],{"class":194},"    // Loop over rss_feeds and spawn threads##$_0A$##    for (key, value) in rss_feeds {##$_0A$##        let thread = thread::spawn(move || {##$_0A$## println!(\"{}\", key);##$_0A$##        });##$_0A$##    }##$_0A$##}\n",[12,2972,2973,231],{},[227,2974],{"alt":2975,"src":2976},"VS Codeターミナル、参照とスレッドのmoveクロージャに関する変数スコープエラー","https://res.cloudinary.com/about-gitlab-com/image/upload/v1782398627/blog/Content%20Images/learn-rust-with-ai-code-suggestions-advanced-programming/vs_code_terminal_cargo_build_error_function_threads_variable_scopes.png",[12,2978,2979,2982,2983,2985,2986,2988,2989,2992],{},[160,2980,2981],{},"key"," 変数は関数スコープ内で作成されていますが、",[160,2984,516],{}," 変数を参照しているため、スレッドスコープに移動することはできません。関数パラメータ ",[160,2987,516],{}," のハッシュマップからアクセスされる値は、",[160,2990,2991],{},"clone()"," を使ってローカルコピーを作成する必要があります。",[12,2994,2995,231],{},[227,2996],{"alt":2997,"src":2998},"VS Codeターミナル、cloneを使用したスレッドの生成","https://res.cloudinary.com/about-gitlab-com/image/upload/v1782398624/blog/Content%20Images/learn-rust-with-ai-code-suggestions-advanced-programming/code_suggestions_rust_thread_spawn_clone.png",[172,3000,3002],{"className":174,"code":3001,"language":176,"meta":177,"style":177},"pub fn get_feeds(rss_feeds: &HashMap\u003CString, String>) {\n\n    // Store threads in vector\n    let mut threads: Vec\u003Cthread::JoinHandle\u003C()>> = Vec::new();\n\n    // Loop over rss_feeds and spawn threads\n    for (name, url) in rss_feeds {\n        let thread_name = name.clone();\n        let thread_url = url.clone();\n        let thread = thread::spawn(move || {\n            // Use thread_name and thread_url as values, see next chapter for instructions.\n\n",[160,3003,3004,3030,3034,3039,3069,3073,3078,3088,3104,3120,3142],{"__ignoreMap":177},[181,3005,3006,3008,3010,3012,3014,3016,3018,3020,3022,3024,3026,3028],{"class":183,"line":184},[181,3007,694],{"class":474},[181,3009,748],{"class":474},[181,3011,751],{"class":361},[181,3013,754],{"class":481},[181,3015,757],{"class":474},[181,3017,760],{"class":474},[181,3019,463],{"class":361},[181,3021,765],{"class":481},[181,3023,768],{"class":361},[181,3025,771],{"class":481},[181,3027,768],{"class":361},[181,3029,2605],{"class":481},[181,3031,3032],{"class":183,"line":191},[181,3033,188],{"emptyLinePlaceholder":187},[181,3035,3036],{"class":183,"line":198},[181,3037,3038],{"class":194},"    // Store threads in vector\n",[181,3040,3041,3043,3045,3047,3049,3051,3053,3055,3057,3059,3061,3063,3065,3067],{"class":183,"line":204},[181,3042,2172],{"class":474},[181,3044,1919],{"class":474},[181,3046,2623],{"class":481},[181,3048,757],{"class":474},[181,3050,2628],{"class":361},[181,3052,2631],{"class":481},[181,3054,554],{"class":474},[181,3056,2636],{"class":361},[181,3058,2639],{"class":481},[181,3060,1572],{"class":474},[181,3062,2628],{"class":361},[181,3064,554],{"class":474},[181,3066,2648],{"class":361},[181,3068,1605],{"class":481},[181,3070,3071],{"class":183,"line":210},[181,3072,188],{"emptyLinePlaceholder":187},[181,3074,3075],{"class":183,"line":393},[181,3076,3077],{"class":194},"    // Loop over rss_feeds and spawn threads\n",[181,3079,3080,3082,3084,3086],{"class":183,"line":411},[181,3081,1877],{"class":474},[181,3083,2667],{"class":481},[181,3085,1883],{"class":474},[181,3087,2672],{"class":481},[181,3089,3090,3092,3094,3096,3098,3100,3102],{"class":183,"line":1991},[181,3091,1916],{"class":474},[181,3093,2679],{"class":481},[181,3095,1572],{"class":474},[181,3097,2684],{"class":481},[181,3099,1591],{"class":474},[181,3101,2689],{"class":361},[181,3103,1605],{"class":481},[181,3105,3106,3108,3110,3112,3114,3116,3118],{"class":183,"line":1996},[181,3107,1916],{"class":474},[181,3109,2698],{"class":481},[181,3111,1572],{"class":474},[181,3113,2703],{"class":481},[181,3115,1591],{"class":474},[181,3117,2689],{"class":361},[181,3119,1605],{"class":481},[181,3121,3122,3124,3126,3128,3130,3132,3134,3136,3138,3140],{"class":183,"line":2002},[181,3123,1916],{"class":474},[181,3125,2716],{"class":481},[181,3127,1572],{"class":474},[181,3129,2721],{"class":361},[181,3131,554],{"class":474},[181,3133,2726],{"class":361},[181,3135,1124],{"class":481},[181,3137,2731],{"class":474},[181,3139,2734],{"class":474},[181,3141,2737],{"class":481},[181,3143,3144],{"class":183,"line":2044},[181,3145,3146],{"class":194},"            // Use thread_name and thread_url as values, see next chapter for instructions.\n",[137,3148,3150],{"id":3149},"フィードのxmlの解析およびオブジェクト型への変換","フィードのXMLの解析およびオブジェクト型への変換",[12,3152,3153],{},"次のステップは、スレッド内のクロージャでRSSフィードの解析手順を繰り返すことです。コード提案の指示とともに以下のコードコメントを追加します。",[282,3155,3156,3166],{},[40,3157,3158,3161,3162,3165],{},[160,3159,3160],{},"// Parse XML body with feed_rs parser, input in bytes","：コード提案に対し、RSSフィードのURLコンテンツを取得し、",[160,3163,3164],{},"feed_rs"," クレートの関数で解析したいという要望を伝えます。",[40,3167,3168,3171,3172,3175,3176,3183],{},[160,3169,3170],{},"// Check feed_type attribute feed_rs::model::FeedType::RSS2 or Atom and print its name","：",[160,3173,3174],{},"feed_type"," 属性を ",[16,3177,3180],{"href":3178,"rel":3179},"https://docs.rs/feed-rs/latest/feed_rs/model/enum.FeedType.html",[],[160,3181,3182],{},"feed_rs::model::FeedType"," と照合してフィードの種類を抽出します。この場合、コード提案に対して、照合の対象とする正確なEnum値を指示する必要があります。",[12,3185,3186,231],{},[227,3187],{"alt":3188,"src":3189},"コード提案に特定のフィードタイプと照合するよう指示","https://res.cloudinary.com/about-gitlab-com/image/upload/v1782398622/blog/Content%20Images/learn-rust-with-ai-code-suggestions-advanced-programming/code_suggestions_feed_rs_type_condition.png",[172,3191,3193],{"className":174,"code":3192,"language":176,"meta":177,"style":177},"\n            // Parse XML body with feed_rs parser, input in bytes\n            let body = reqwest::blocking::get(thread_url).unwrap().bytes().unwrap();\n            let feed = feed_rs::parser::parse(body.as_ref()).unwrap();\n\n            // Check feed_type attribute feed_rs::model::FeedType::RSS2 or Atom and print its name\n            if feed.feed_type == feed_rs::model::FeedType::RSS2 {\n                println!(\"{} is an RSS2 feed\", thread_name);\n            } else if feed.feed_type == feed_rs::model::FeedType::Atom {\n                println!(\"{} is an Atom feed\", thread_name);\n            }\n\n",[160,3194,3195,3199,3203,3246,3280,3284,3289,3324,3337,3373,3384],{"__ignoreMap":177},[181,3196,3197],{"class":183,"line":184},[181,3198,188],{"emptyLinePlaceholder":187},[181,3200,3201],{"class":183,"line":191},[181,3202,1561],{"class":194},[181,3204,3205,3207,3210,3212,3215,3217,3219,3221,3224,3227,3229,3231,3233,3235,3238,3240,3242,3244],{"class":183,"line":198},[181,3206,1566],{"class":474},[181,3208,3209],{"class":481}," body ",[181,3211,1572],{"class":474},[181,3213,3214],{"class":361}," reqwest",[181,3216,554],{"class":474},[181,3218,1354],{"class":361},[181,3220,554],{"class":474},[181,3222,3223],{"class":361},"get",[181,3225,3226],{"class":481},"(thread_url)",[181,3228,1591],{"class":474},[181,3230,1602],{"class":361},[181,3232,1898],{"class":481},[181,3234,1591],{"class":474},[181,3236,3237],{"class":361},"bytes",[181,3239,1898],{"class":481},[181,3241,1591],{"class":474},[181,3243,1602],{"class":361},[181,3245,1605],{"class":481},[181,3247,3248,3250,3253,3255,3257,3259,3261,3263,3265,3267,3269,3272,3274,3276,3278],{"class":183,"line":204},[181,3249,1566],{"class":474},[181,3251,3252],{"class":481}," feed ",[181,3254,1572],{"class":474},[181,3256,1575],{"class":361},[181,3258,554],{"class":474},[181,3260,1580],{"class":361},[181,3262,554],{"class":474},[181,3264,1585],{"class":361},[181,3266,1588],{"class":481},[181,3268,1591],{"class":474},[181,3270,3271],{"class":361},"as_ref",[181,3273,1597],{"class":481},[181,3275,1591],{"class":474},[181,3277,1602],{"class":361},[181,3279,1605],{"class":481},[181,3281,3282],{"class":183,"line":210},[181,3283,188],{"emptyLinePlaceholder":187},[181,3285,3286],{"class":183,"line":393},[181,3287,3288],{"class":194},"            // Check feed_type attribute feed_rs::model::FeedType::RSS2 or Atom and print its name\n",[181,3290,3291,3294,3297,3299,3302,3305,3307,3309,3312,3314,3317,3319,3322],{"class":183,"line":411},[181,3292,3293],{"class":474},"            if",[181,3295,3296],{"class":481}," feed",[181,3298,1591],{"class":474},[181,3300,3301],{"class":481},"feed_type ",[181,3303,3304],{"class":474},"==",[181,3306,1575],{"class":361},[181,3308,554],{"class":474},[181,3310,3311],{"class":361},"model",[181,3313,554],{"class":474},[181,3315,3316],{"class":361},"FeedType",[181,3318,554],{"class":474},[181,3320,3321],{"class":371},"RSS2",[181,3323,2737],{"class":481},[181,3325,3326,3329,3331,3334],{"class":183,"line":1991},[181,3327,3328],{"class":361},"                println!",[181,3330,1124],{"class":481},[181,3332,3333],{"class":365},"\"{} is an RSS2 feed\"",[181,3335,3336],{"class":481},", thread_name);\n",[181,3338,3339,3342,3345,3348,3350,3352,3354,3356,3358,3360,3362,3364,3366,3368,3371],{"class":183,"line":1996},[181,3340,3341],{"class":481},"            } ",[181,3343,3344],{"class":474},"else",[181,3346,3347],{"class":474}," if",[181,3349,3296],{"class":481},[181,3351,1591],{"class":474},[181,3353,3301],{"class":481},[181,3355,3304],{"class":474},[181,3357,1575],{"class":361},[181,3359,554],{"class":474},[181,3361,3311],{"class":361},[181,3363,554],{"class":474},[181,3365,3316],{"class":361},[181,3367,554],{"class":474},[181,3369,3370],{"class":361},"Atom",[181,3372,2737],{"class":481},[181,3374,3375,3377,3379,3382],{"class":183,"line":2002},[181,3376,3328],{"class":361},[181,3378,1124],{"class":481},[181,3380,3381],{"class":365},"\"{} is an Atom feed\"",[181,3383,3336],{"class":481},[181,3385,3386],{"class":183,"line":2044},[181,3387,3388],{"class":481},"            }\n",[12,3390,3391],{},"プログラムをもう一度ビルドして実行し、出力を確認します。",[172,3393,3396],{"className":3394,"code":3395,"language":1056,"meta":177},[1054],"time cargo run -- \"GitLab Blog,https://about.gitlab.com/atom.xml\" \"CNCF,https://www.cncf.io/feed/\"\n\nCNCF is an RSS2 feed\nTechCrunch is an RSS2 feed\nGitLab Blog is an Atom feed\nHacker News is an RSS2 feed\n",[160,3397,3395],{"__ignoreMap":177},[12,3399,3400],{},"フィードURLをブラウザで開くか、以前にダウンロードしたファイルを調べて、この出力を確認します。",[12,3402,3403,3404,3407],{},"Hacker News はRSS 2.0をサポートしており、",[160,3405,3406],{},"channel(title,link,description,item(title,link,pubDate,comments))"," の構造を持っています。TechCrunchとCNCFブログは同様の構造をしています。",[172,3409,3413],{"className":3410,"code":3411,"language":3412,"meta":177,"style":177},"language-xml shiki shiki-themes github-light","\u003Crss version=\"2.0\">\u003Cchannel>\u003Ctitle>Hacker News\u003C/title>\u003Clink>https://news.ycombinator.com/\u003C/link>\u003Cdescription>Links for the intellectually curious, ranked by readers.\u003C/description>\u003Citem>\u003Ctitle>Writing a debugger from scratch: Breakpoints\u003C/title>\u003Clink>https://www.timdbg.com/posts/writing-a-debugger-from-scratch-part-5/\u003C/link>\u003CpubDate>Wed, 27 Sep 2023 06:31:25 +0000\u003C/pubDate>\u003Ccomments>https://news.ycombinator.com/item?id=37670938\u003C/comments>\u003Cdescription>\u003C![CDATA[\u003Ca href=\"https://news.ycombinator.com/item?id=37670938\">Comments\u003C/a>]]>\u003C/description>\u003C/item>\u003Citem>\n","xml",[160,3414,3415],{"__ignoreMap":177},[181,3416,3417,3419,3423,3425,3427,3430,3433,3436,3438,3441,3444,3446,3448,3451,3454,3456,3458,3461,3464,3466,3468,3471,3473,3475,3478,3480,3482,3484,3487,3489,3491,3494,3497,3499,3501,3504,3507,3509,3511,3513,3516,3519,3522,3524,3527,3529,3531,3533],{"class":183,"line":184},[181,3418,765],{"class":481},[181,3420,3422],{"class":3421},"shJU0","rss",[181,3424,1406],{"class":361},[181,3426,1572],{"class":481},[181,3428,3429],{"class":365},"\"2.0\"",[181,3431,3432],{"class":481},">\u003C",[181,3434,3435],{"class":3421},"channel",[181,3437,3432],{"class":481},[181,3439,3440],{"class":3421},"title",[181,3442,3443],{"class":481},">Hacker News\u003C/",[181,3445,3440],{"class":3421},[181,3447,3432],{"class":481},[181,3449,3450],{"class":3421},"link",[181,3452,3453],{"class":481},">https://news.ycombinator.com/\u003C/",[181,3455,3450],{"class":3421},[181,3457,3432],{"class":481},[181,3459,3460],{"class":3421},"description",[181,3462,3463],{"class":481},">Links for the intellectually curious, ranked by readers.\u003C/",[181,3465,3460],{"class":3421},[181,3467,3432],{"class":481},[181,3469,3470],{"class":3421},"item",[181,3472,3432],{"class":481},[181,3474,3440],{"class":3421},[181,3476,3477],{"class":481},">Writing a debugger from scratch: Breakpoints\u003C/",[181,3479,3440],{"class":3421},[181,3481,3432],{"class":481},[181,3483,3450],{"class":3421},[181,3485,3486],{"class":481},">https://www.timdbg.com/posts/writing-a-debugger-from-scratch-part-5/\u003C/",[181,3488,3450],{"class":3421},[181,3490,3432],{"class":481},[181,3492,3493],{"class":3421},"pubDate",[181,3495,3496],{"class":481},">Wed, 27 Sep 2023 06:31:25 +0000\u003C/",[181,3498,3493],{"class":3421},[181,3500,3432],{"class":481},[181,3502,3503],{"class":3421},"comments",[181,3505,3506],{"class":481},">https://news.ycombinator.com/item?id=37670938\u003C/",[181,3508,3503],{"class":3421},[181,3510,3432],{"class":481},[181,3512,3460],{"class":3421},[181,3514,3515],{"class":481},">",[181,3517,3518],{"class":365},"\u003C![CDATA[\u003Ca href=\"https://news.ycombinator.com/item?id=37670938\">Comments\u003C/a>]]>",[181,3520,3521],{"class":481},"\u003C/",[181,3523,3460],{"class":3421},[181,3525,3526],{"class":481},">\u003C/",[181,3528,3470],{"class":3421},[181,3530,3432],{"class":481},[181,3532,3470],{"class":3421},[181,3534,3535],{"class":481},">\n",[12,3537,3538,3539,3543],{},"GitLabブログには",[16,3540,3370],{"href":3541,"rel":3542},"https://datatracker.ietf.org/doc/html/rfc4287",[],"フィード形式が使用されています。RSSに類似していますが異なる解析ロジックが必要です。",[172,3545,3547],{"className":3410,"code":3546,"language":3412,"meta":177,"style":177},"\u003C?xml version='1.0' encoding='utf-8' ?>\n\u003Cfeed xmlns='http://www.w3.org/2005/Atom'>\n\u003C!-- / Get release posts -->\n\u003C!-- / Get blog posts -->\n\u003Ctitle>GitLab\u003C/title>\n\u003Cid>https://about.gitlab.com/blog\u003C/id>\n\u003Clink href='https://about.gitlab.com/blog/' />\n\u003Cupdated>2023-09-26T00:00:00+00:00\u003C/updated>\n\u003Cauthor>\n\u003Cname>The GitLab Team\u003C/name>\n\u003C/author>\n\u003Centry>\n\u003Ctitle>Atlassian Server ending: Goodbye disjointed toolchain, hello DevSecOps platform\u003C/title>\n\u003Clink href='https://about.gitlab.com/blog/atlassian-server-ending-move-to-a-single-devsecops-platform/' rel='alternate' />\n\u003Cid>https://about.gitlab.com/blog/atlassian-server-ending-move-to-a-single-devsecops-platform/\u003C/id>\n\u003Cpublished>2023-09-26T00:00:00+00:00\u003C/published>\n\u003Cupdated>2023-09-26T00:00:00+00:00\u003C/updated>\n\u003Cauthor>\n\u003Cname>Dave Steer, Justin Farris\u003C/name>\n\u003C/author>\n",[160,3548,3549,3574,3591,3596,3601,3614,3628,3645,3659,3668,3682,3690,3699,3712,3735,3748,3761,3773,3781,3794],{"__ignoreMap":177},[181,3550,3551,3554,3556,3558,3560,3563,3566,3568,3571],{"class":183,"line":184},[181,3552,3553],{"class":481},"\u003C?",[181,3555,3412],{"class":3421},[181,3557,1406],{"class":361},[181,3559,1572],{"class":481},[181,3561,3562],{"class":365},"'1.0'",[181,3564,3565],{"class":361}," encoding",[181,3567,1572],{"class":481},[181,3569,3570],{"class":365},"'utf-8'",[181,3572,3573],{"class":481}," ?>\n",[181,3575,3576,3578,3581,3584,3586,3589],{"class":183,"line":191},[181,3577,765],{"class":481},[181,3579,3580],{"class":3421},"feed",[181,3582,3583],{"class":361}," xmlns",[181,3585,1572],{"class":481},[181,3587,3588],{"class":365},"'http://www.w3.org/2005/Atom'",[181,3590,3535],{"class":481},[181,3592,3593],{"class":183,"line":198},[181,3594,3595],{"class":194},"\u003C!-- / Get release posts -->\n",[181,3597,3598],{"class":183,"line":204},[181,3599,3600],{"class":194},"\u003C!-- / Get blog posts -->\n",[181,3602,3603,3605,3607,3610,3612],{"class":183,"line":210},[181,3604,765],{"class":481},[181,3606,3440],{"class":3421},[181,3608,3609],{"class":481},">GitLab\u003C/",[181,3611,3440],{"class":3421},[181,3613,3535],{"class":481},[181,3615,3616,3618,3621,3624,3626],{"class":183,"line":393},[181,3617,765],{"class":481},[181,3619,3620],{"class":3421},"id",[181,3622,3623],{"class":481},">https://about.gitlab.com/blog\u003C/",[181,3625,3620],{"class":3421},[181,3627,3535],{"class":481},[181,3629,3630,3632,3634,3637,3639,3642],{"class":183,"line":411},[181,3631,765],{"class":481},[181,3633,3450],{"class":3421},[181,3635,3636],{"class":361}," href",[181,3638,1572],{"class":481},[181,3640,3641],{"class":365},"'https://about.gitlab.com/blog/'",[181,3643,3644],{"class":481}," />\n",[181,3646,3647,3649,3652,3655,3657],{"class":183,"line":1991},[181,3648,765],{"class":481},[181,3650,3651],{"class":3421},"updated",[181,3653,3654],{"class":481},">2023-09-26T00:00:00+00:00\u003C/",[181,3656,3651],{"class":3421},[181,3658,3535],{"class":481},[181,3660,3661,3663,3666],{"class":183,"line":1996},[181,3662,765],{"class":481},[181,3664,3665],{"class":3421},"author",[181,3667,3535],{"class":481},[181,3669,3670,3672,3675,3678,3680],{"class":183,"line":2002},[181,3671,765],{"class":481},[181,3673,3674],{"class":3421},"name",[181,3676,3677],{"class":481},">The GitLab Team\u003C/",[181,3679,3674],{"class":3421},[181,3681,3535],{"class":481},[181,3683,3684,3686,3688],{"class":183,"line":2044},[181,3685,3521],{"class":481},[181,3687,3665],{"class":3421},[181,3689,3535],{"class":481},[181,3691,3692,3694,3697],{"class":183,"line":2058},[181,3693,765],{"class":481},[181,3695,3696],{"class":3421},"entry",[181,3698,3535],{"class":481},[181,3700,3701,3703,3705,3708,3710],{"class":183,"line":2064},[181,3702,765],{"class":481},[181,3704,3440],{"class":3421},[181,3706,3707],{"class":481},">Atlassian Server ending: Goodbye disjointed toolchain, hello DevSecOps platform\u003C/",[181,3709,3440],{"class":3421},[181,3711,3535],{"class":481},[181,3713,3714,3716,3718,3720,3722,3725,3728,3730,3733],{"class":183,"line":2069},[181,3715,765],{"class":481},[181,3717,3450],{"class":3421},[181,3719,3636],{"class":361},[181,3721,1572],{"class":481},[181,3723,3724],{"class":365},"'https://about.gitlab.com/blog/atlassian-server-ending-move-to-a-single-devsecops-platform/'",[181,3726,3727],{"class":361}," rel",[181,3729,1572],{"class":481},[181,3731,3732],{"class":365},"'alternate'",[181,3734,3644],{"class":481},[181,3736,3737,3739,3741,3744,3746],{"class":183,"line":2098},[181,3738,765],{"class":481},[181,3740,3620],{"class":3421},[181,3742,3743],{"class":481},">https://about.gitlab.com/blog/atlassian-server-ending-move-to-a-single-devsecops-platform/\u003C/",[181,3745,3620],{"class":3421},[181,3747,3535],{"class":481},[181,3749,3750,3752,3755,3757,3759],{"class":183,"line":2766},[181,3751,765],{"class":481},[181,3753,3754],{"class":3421},"published",[181,3756,3654],{"class":481},[181,3758,3754],{"class":3421},[181,3760,3535],{"class":481},[181,3762,3763,3765,3767,3769,3771],{"class":183,"line":2771},[181,3764,765],{"class":481},[181,3766,3651],{"class":3421},[181,3768,3654],{"class":481},[181,3770,3651],{"class":3421},[181,3772,3535],{"class":481},[181,3774,3775,3777,3779],{"class":183,"line":2777},[181,3776,765],{"class":481},[181,3778,3665],{"class":3421},[181,3780,3535],{"class":481},[181,3782,3783,3785,3787,3790,3792],{"class":183,"line":2789},[181,3784,765],{"class":481},[181,3786,3674],{"class":3421},[181,3788,3789],{"class":481},">Dave Steer, Justin Farris\u003C/",[181,3791,3674],{"class":3421},[181,3793,3535],{"class":481},[181,3795,3796,3798,3800],{"class":183,"line":2808},[181,3797,3521],{"class":481},[181,3799,3665],{"class":3421},[181,3801,3535],{"class":481},[154,3803,110],{"id":110},[12,3805,3806,3813,3814,3821,3822,3824],{},[16,3807,3810],{"href":3808,"rel":3809},"https://docs.rs/roxmltree/latest/roxmltree/struct.Document.html",[],[160,3811,3812],{},"roxmltree::Document::parse"," を使用する場合、XMLノードツリーとその特定のタグ名を理解する必要があります。幸い、",[16,3815,3818],{"href":3816,"rel":3817},"https://docs.rs/feed-rs/latest/feed_rs/model/struct.Feed.html",[],[160,3819,3820],{},"feed_rs::model::Feed"," はRSSとAtomフィードの統合モデルを提供しているため、引き続き ",[160,3823,3164],{}," クレートを使用して進めましょう。",[282,3826,3827,3830],{},[40,3828,3829],{},"Atom：Feed->Feed、Entry->Entry",[40,3831,3832],{},"RSS：Channel->Feed、Item->Entry",[12,3834,3835,3836,3841,3842,3844],{},"上記のマッピングに加えて、必要な属性を抽出し、それらのデータ型をマッピングする必要があります。",[16,3837,3840],{"href":3838,"rel":3839},"https://docs.rs/feed-rs/latest/feed_rs/model/index.html",[],"feed_rs::modelのドキュメント","を開き、構造体やそのフィールド、実装について理解しながら進めることをお勧めします。これは、",[160,3843,3164],{}," の実装に特有の型変換エラーやコンパイルエラーが発生するのを防ぐためです。",[12,3846,3847,3853,3854,3856,3857,3860,3861,3868],{},[16,3848,3850],{"href":3816,"rel":3849},[],[160,3851,3852],{},"Feed"," 構造体は ",[160,3855,3440],{}," を提供しますが、その型は ",[160,3858,3859],{},"Option\u003CText>"," で、値が設定されているか、何もないかのいずれかです。",[16,3862,3865],{"href":3863,"rel":3864},"https://docs.rs/feed-rs/latest/feed_rs/model/struct.Entry.html",[],[160,3866,3867],{},"Entry"," 構造体は以下の情報を提供します。",[282,3870,3871,3892,3916,3932],{},[40,3872,3873,3171,3875,3877,3878,3884,3885,3888,3889,3891],{},[160,3874,3440],{},[160,3876,3859],{}," 型で、",[16,3879,3882],{"href":3880,"rel":3881},"https://docs.rs/feed-rs/latest/feed_rs/model/struct.Text.html",[],[160,3883,981],{}," には ",[160,3886,3887],{},"content"," フィールドが ",[160,3890,768],{}," 型として含まれています。",[40,3893,3894,3171,3896,3877,3899,3906,3907,3915],{},[160,3895,3754],{},[160,3897,3898],{},"Option\u003CDateTime\u003CUtc>>",[16,3900,3903],{"href":3901,"rel":3902},"https://docs.rs/chrono/latest/chrono/struct.DateTime.html",[],[160,3904,3905],{},"DateTime"," は ",[16,3908,3911,3914],{"href":3909,"rel":3910},"https://docs.rs/chrono/latest/chrono/struct.DateTime.html#method.format",[],[160,3912,3913],{},"format()"," メソッド","を持ちます。",[40,3917,3918,3171,3921,3877,3923,3884,3928,3888,3930,3891],{},[160,3919,3920],{},"summary",[160,3922,3859],{},[16,3924,3926],{"href":3880,"rel":3925},[],[160,3927,981],{},[160,3929,3887],{},[160,3931,768],{},[40,3933,3934,3171,3937,3877,3940,3947,3948,3951],{},[160,3935,3936],{},"links",[160,3938,3939],{},"Vec\u003CLink>",[16,3941,3944],{"href":3942,"rel":3943},"https://docs.rs/feed-rs/latest/feed_rs/model/struct.Link.html",[],[160,3945,3946],{},"Link"," 項目のベクターです。",[160,3949,3950],{},"href"," 属性が生のURL文字列を提供します。",[12,3953,3954,3955,3957,3958,3960],{},"1から4に従って、フィードエントリから必要なデータを抽出します。繰り返しますが、すべての ",[160,3956,976],{}," 型には ",[160,3959,964],{}," を呼び出す必要があります。このため、コード提案に対してより直接的な指示が求められます。",[172,3962,3964],{"className":174,"code":3963,"language":176,"meta":177,"style":177},"\n                // https://docs.rs/feed-rs/latest/feed_rs/model/struct.Feed.html\n                // https://docs.rs/feed-rs/latest/feed_rs/model/struct.Entry.html\n                // Loop over all entries, and print\n                // title.unwrap().content\n                // published.unwrap().format\n                // summary.unwrap().content\n                // links href as joined string\n                for entry in feed.entries {\n                    println!(\"Title: {}\", entry.title.unwrap().content);\n                    println!(\"Published: {}\", entry.published.unwrap().format(\"%Y-%m-%d %H:%M:%S\"));\n                    println!(\"Summary: {}\", entry.summary.unwrap().content);\n                    println!(\"Links: {:?}\", entry.links.iter().map(|link| link.href.clone()).collect::\u003CVec\u003CString>>().join(\", \"));\n                    println!();\n                }\n\n",[160,3965,3966,3970,3975,3980,3985,3990,3995,4000,4005,4022,4050,4082,4107,4186,4192],{"__ignoreMap":177},[181,3967,3968],{"class":183,"line":184},[181,3969,188],{"emptyLinePlaceholder":187},[181,3971,3972],{"class":183,"line":191},[181,3973,3974],{"class":194},"                // https://docs.rs/feed-rs/latest/feed_rs/model/struct.Feed.html\n",[181,3976,3977],{"class":183,"line":198},[181,3978,3979],{"class":194},"                // https://docs.rs/feed-rs/latest/feed_rs/model/struct.Entry.html\n",[181,3981,3982],{"class":183,"line":204},[181,3983,3984],{"class":194},"                // Loop over all entries, and print\n",[181,3986,3987],{"class":183,"line":210},[181,3988,3989],{"class":194},"                // title.unwrap().content\n",[181,3991,3992],{"class":183,"line":393},[181,3993,3994],{"class":194},"                // published.unwrap().format\n",[181,3996,3997],{"class":183,"line":411},[181,3998,3999],{"class":194},"                // summary.unwrap().content\n",[181,4001,4002],{"class":183,"line":1991},[181,4003,4004],{"class":194},"                // links href as joined string\n",[181,4006,4007,4010,4013,4015,4017,4019],{"class":183,"line":1996},[181,4008,4009],{"class":474},"                for",[181,4011,4012],{"class":481}," entry ",[181,4014,1883],{"class":474},[181,4016,3296],{"class":481},[181,4018,1591],{"class":474},[181,4020,4021],{"class":481},"entries {\n",[181,4023,4024,4027,4029,4032,4035,4037,4039,4041,4043,4045,4047],{"class":183,"line":2002},[181,4025,4026],{"class":361},"                    println!",[181,4028,1124],{"class":481},[181,4030,4031],{"class":365},"\"Title: {}\"",[181,4033,4034],{"class":481},", entry",[181,4036,1591],{"class":474},[181,4038,3440],{"class":481},[181,4040,1591],{"class":474},[181,4042,1602],{"class":361},[181,4044,1898],{"class":481},[181,4046,1591],{"class":474},[181,4048,4049],{"class":481},"content);\n",[181,4051,4052,4054,4056,4059,4061,4063,4065,4067,4069,4071,4073,4075,4077,4080],{"class":183,"line":2044},[181,4053,4026],{"class":361},[181,4055,1124],{"class":481},[181,4057,4058],{"class":365},"\"Published: {}\"",[181,4060,4034],{"class":481},[181,4062,1591],{"class":474},[181,4064,3754],{"class":481},[181,4066,1591],{"class":474},[181,4068,1602],{"class":361},[181,4070,1898],{"class":481},[181,4072,1591],{"class":474},[181,4074,2285],{"class":361},[181,4076,1124],{"class":481},[181,4078,4079],{"class":365},"\"%Y-%m-%d %H:%M:%S\"",[181,4081,2293],{"class":481},[181,4083,4084,4086,4088,4091,4093,4095,4097,4099,4101,4103,4105],{"class":183,"line":2058},[181,4085,4026],{"class":361},[181,4087,1124],{"class":481},[181,4089,4090],{"class":365},"\"Summary: {}\"",[181,4092,4034],{"class":481},[181,4094,1591],{"class":474},[181,4096,3920],{"class":481},[181,4098,1591],{"class":474},[181,4100,1602],{"class":361},[181,4102,1898],{"class":481},[181,4104,1591],{"class":474},[181,4106,4049],{"class":481},[181,4108,4109,4111,4113,4116,4118,4120,4122,4124,4127,4129,4131,4134,4136,4139,4141,4143,4146,4148,4150,4152,4154,4156,4158,4161,4163,4165,4168,4170,4172,4175,4177,4179,4181,4184],{"class":183,"line":2064},[181,4110,4026],{"class":361},[181,4112,1124],{"class":481},[181,4114,4115],{"class":365},"\"Links: {:?}\"",[181,4117,4034],{"class":481},[181,4119,1591],{"class":474},[181,4121,3936],{"class":481},[181,4123,1591],{"class":474},[181,4125,4126],{"class":361},"iter",[181,4128,1898],{"class":481},[181,4130,1591],{"class":474},[181,4132,4133],{"class":361},"map",[181,4135,1124],{"class":481},[181,4137,4138],{"class":474},"|",[181,4140,3450],{"class":481},[181,4142,4138],{"class":474},[181,4144,4145],{"class":481}," link",[181,4147,1591],{"class":474},[181,4149,3950],{"class":481},[181,4151,1591],{"class":474},[181,4153,2689],{"class":361},[181,4155,1597],{"class":481},[181,4157,1591],{"class":474},[181,4159,4160],{"class":361},"collect",[181,4162,554],{"class":474},[181,4164,765],{"class":481},[181,4166,4167],{"class":361},"Vec",[181,4169,765],{"class":481},[181,4171,768],{"class":361},[181,4173,4174],{"class":481},">>()",[181,4176,1591],{"class":474},[181,4178,2797],{"class":361},[181,4180,1124],{"class":481},[181,4182,4183],{"class":365},"\", \"",[181,4185,2293],{"class":481},[181,4187,4188,4190],{"class":183,"line":2069},[181,4189,4026],{"class":361},[181,4191,1605],{"class":481},[181,4193,4194],{"class":183,"line":2098},[181,4195,4196],{"class":481},"                }\n",[12,4198,4199,231],{},[227,4200],{"alt":4201,"src":4202},"特定の要件に基づいてフィードエントリの型を出力するためのコード提案","https://res.cloudinary.com/about-gitlab-com/image/upload/v1782398622/blog/Content%20Images/learn-rust-with-ai-code-suggestions-advanced-programming/code_suggestions_print_feed_entries_fields_with_rust_type_specifics.png",[154,4204,113],{"id":4205},"optionunwrapによるエラーハンドリング",[12,4207,4208,4209,4211,4212,4215,4216,4218],{},"プログラムを再ビルドして実行した後、複数行の指示を引き続き処理します。補足：",[160,4210,964],{}," は空の値に遭遇すると ",[160,4213,4214],{},"panic!"," マクロを呼び出し、プログラムを強制終了させます。これは、フィードデータ内に ",[160,4217,3920],{}," のようなフィールドが設定されていない場合に発生します。",[172,4220,4222],{"className":352,"code":4221,"language":354,"meta":177,"style":177},"GitLab Blog is an Atom feed\nTitle: How the Colmena project uses GitLab to support citizen journalists\nPublished: 2023-09-27 00:00:00\nthread '\u003Cunnamed>' panicked at 'called `Option::unwrap()` on a `None` value', src/feed_reader.rs:40:59\n",[160,4223,4224,4244,4279,4290],{"__ignoreMap":177},[181,4225,4226,4229,4232,4235,4238,4241],{"class":183,"line":184},[181,4227,4228],{"class":361},"GitLab",[181,4230,4231],{"class":365}," Blog",[181,4233,4234],{"class":365}," is",[181,4236,4237],{"class":365}," an",[181,4239,4240],{"class":365}," Atom",[181,4242,4243],{"class":365}," feed\n",[181,4245,4246,4249,4252,4255,4258,4261,4264,4267,4270,4273,4276],{"class":183,"line":191},[181,4247,4248],{"class":361},"Title:",[181,4250,4251],{"class":365}," How",[181,4253,4254],{"class":365}," the",[181,4256,4257],{"class":365}," Colmena",[181,4259,4260],{"class":365}," project",[181,4262,4263],{"class":365}," uses",[181,4265,4266],{"class":365}," GitLab",[181,4268,4269],{"class":365}," to",[181,4271,4272],{"class":365}," support",[181,4274,4275],{"class":365}," citizen",[181,4277,4278],{"class":365}," journalists\n",[181,4280,4281,4284,4287],{"class":183,"line":198},[181,4282,4283],{"class":361},"Published:",[181,4285,4286],{"class":365}," 2023-09-27",[181,4288,4289],{"class":365}," 00:00:00\n",[181,4291,4292,4294,4297,4300,4303,4306],{"class":183,"line":204},[181,4293,2516],{"class":361},[181,4295,4296],{"class":365}," '\u003Cunnamed>'",[181,4298,4299],{"class":365}," panicked",[181,4301,4302],{"class":365}," at",[181,4304,4305],{"class":365}," 'called `Option::unwrap()` on a `None` value',",[181,4307,4308],{"class":365}," src/feed_reader.rs:40:59\n",[12,4310,4311,4312,4319,4320,4322],{},"解決策のひとつとして、",[16,4313,4316],{"href":4314,"rel":4315},"https://doc.rust-lang.org/std/option/enum.Option.html#method.unwrap_or_else",[],[160,4317,4318],{},"std::Option::unwrap_or_else"," を使用し、デフォルト値として空の文字列を設定することが挙げられます。この構文には、空の ",[160,4321,981],{}," 構造体のインスタンスを返すクロージャが必要です。",[12,4324,4325],{},"問題を解決する上で、正しい初期化方法を見つけるために試行錯誤を重ねました。単に空の文字列を渡すだけではカスタム型ではうまく機能しませんでした。以下に、筆者が試したすべてのアプローチとリサーチの過程をまとめました。",[172,4327,4329],{"className":174,"code":4328,"language":176,"meta":177,"style":177},"// Problem: The `summary` attribute is not always initialized. unwrap() will panic! then.\n// Requires use mime; and use feed_rs::model::Text;\n/*\n// 1st attempt: Use unwrap() to extraxt Text from Option\u003CText> type.\nprintln!(\"Summary: {}\", entry.summary.unwrap().content);\n// 2nd attempt. Learned about unwrap_or_else, passing an empty string.\nprintln!(\"Summary: {}\", entry.summary.unwrap_or_else(|| \"\").content);\n// 3rd attempt. summary is of the Text type, pass a new struct instantiation.\nprintln!(\"Summary: {}\", entry.summary.unwrap_or_else(|| Text{}).content);\n// 4th attempt. Struct instantiation requires 3 field values.\nprintln!(\"Summary: {}\", entry.summary.unwrap_or_else(|| Text{\"\", \"\", \"\"}).content);\n// 5th attempt. Struct instantation with public fields requires key: value syntax\nprintln!(\"Summary: {}\", entry.summary.unwrap_or_else(|| Text{content_type: \"\", src: \"\", content: \"\"}).content);\n// 6th attempt. Reviewed expected Text types in https://docs.rs/feed-rs/latest/feed_rs/model/struct.Text.html and created Mime and String objects\nprintln!(\"Summary: {}\", entry.summary.unwrap_or_else(|| Text{content_type: mime::TEXT_PLAIN, src: String::new(), content: String::new()}).content);\n// 7th attempt: String and Option\u003CString> cannot be casted automagically. Compiler suggested using `Option::Some()`.\nprintln!(\"Summary: {}\", entry.summary.unwrap_or_else(|| Text{content_type: mime::TEXT_PLAIN, src: Option::Some(), content: String::new()}).content);\n*/\n\n// xth attempt: Solution. Option::Some() requires a new String object.\nprintln!(\"Summary: {}\", entry.summary.unwrap_or_else(|| Text{content_type: mime::TEXT_PLAIN, src: Option::Some(String::new()), content: String::new()}).content);\n",[160,4330,4331,4336,4341,4346,4351,4356,4361,4366,4371,4376,4381,4386,4391,4396,4401,4406,4411,4416,4421,4425,4430],{"__ignoreMap":177},[181,4332,4333],{"class":183,"line":184},[181,4334,4335],{"class":194},"// Problem: The `summary` attribute is not always initialized. unwrap() will panic! then.\n",[181,4337,4338],{"class":183,"line":191},[181,4339,4340],{"class":194},"// Requires use mime; and use feed_rs::model::Text;\n",[181,4342,4343],{"class":183,"line":198},[181,4344,4345],{"class":194},"/*\n",[181,4347,4348],{"class":183,"line":204},[181,4349,4350],{"class":194},"// 1st attempt: Use unwrap() to extraxt Text from Option\u003CText> type.\n",[181,4352,4353],{"class":183,"line":210},[181,4354,4355],{"class":194},"println!(\"Summary: {}\", entry.summary.unwrap().content);\n",[181,4357,4358],{"class":183,"line":393},[181,4359,4360],{"class":194},"// 2nd attempt. Learned about unwrap_or_else, passing an empty string.\n",[181,4362,4363],{"class":183,"line":411},[181,4364,4365],{"class":194},"println!(\"Summary: {}\", entry.summary.unwrap_or_else(|| \"\").content);\n",[181,4367,4368],{"class":183,"line":1991},[181,4369,4370],{"class":194},"// 3rd attempt. summary is of the Text type, pass a new struct instantiation.\n",[181,4372,4373],{"class":183,"line":1996},[181,4374,4375],{"class":194},"println!(\"Summary: {}\", entry.summary.unwrap_or_else(|| Text{}).content);\n",[181,4377,4378],{"class":183,"line":2002},[181,4379,4380],{"class":194},"// 4th attempt. Struct instantiation requires 3 field values.\n",[181,4382,4383],{"class":183,"line":2044},[181,4384,4385],{"class":194},"println!(\"Summary: {}\", entry.summary.unwrap_or_else(|| Text{\"\", \"\", \"\"}).content);\n",[181,4387,4388],{"class":183,"line":2058},[181,4389,4390],{"class":194},"// 5th attempt. Struct instantation with public fields requires key: value syntax\n",[181,4392,4393],{"class":183,"line":2064},[181,4394,4395],{"class":194},"println!(\"Summary: {}\", entry.summary.unwrap_or_else(|| Text{content_type: \"\", src: \"\", content: \"\"}).content);\n",[181,4397,4398],{"class":183,"line":2069},[181,4399,4400],{"class":194},"// 6th attempt. Reviewed expected Text types in https://docs.rs/feed-rs/latest/feed_rs/model/struct.Text.html and created Mime and String objects\n",[181,4402,4403],{"class":183,"line":2098},[181,4404,4405],{"class":194},"println!(\"Summary: {}\", entry.summary.unwrap_or_else(|| Text{content_type: mime::TEXT_PLAIN, src: String::new(), content: String::new()}).content);\n",[181,4407,4408],{"class":183,"line":2766},[181,4409,4410],{"class":194},"// 7th attempt: String and Option\u003CString> cannot be casted automagically. Compiler suggested using `Option::Some()`.\n",[181,4412,4413],{"class":183,"line":2771},[181,4414,4415],{"class":194},"println!(\"Summary: {}\", entry.summary.unwrap_or_else(|| Text{content_type: mime::TEXT_PLAIN, src: Option::Some(), content: String::new()}).content);\n",[181,4417,4418],{"class":183,"line":2777},[181,4419,4420],{"class":194},"*/\n",[181,4422,4423],{"class":183,"line":2789},[181,4424,188],{"emptyLinePlaceholder":187},[181,4426,4427],{"class":183,"line":2808},[181,4428,4429],{"class":194},"// xth attempt: Solution. Option::Some() requires a new String object.\n",[181,4431,4432,4435,4437,4439,4441,4443,4445,4447,4450,4452,4454,4457,4460,4462,4465,4467,4470,4473,4475,4478,4480,4483,4485,4487,4489,4491,4494,4496,4499,4501,4503,4506,4508],{"class":183,"line":2813},[181,4433,4434],{"class":361},"println!",[181,4436,1124],{"class":481},[181,4438,4090],{"class":365},[181,4440,4034],{"class":481},[181,4442,1591],{"class":474},[181,4444,3920],{"class":481},[181,4446,1591],{"class":474},[181,4448,4449],{"class":361},"unwrap_or_else",[181,4451,1124],{"class":481},[181,4453,2895],{"class":474},[181,4455,4456],{"class":361}," Text",[181,4458,4459],{"class":481},"{content_type",[181,4461,757],{"class":474},[181,4463,4464],{"class":361}," mime",[181,4466,554],{"class":474},[181,4468,4469],{"class":371},"TEXT_PLAIN",[181,4471,4472],{"class":481},", src",[181,4474,757],{"class":474},[181,4476,4477],{"class":361}," Option",[181,4479,554],{"class":474},[181,4481,4482],{"class":361},"Some",[181,4484,1124],{"class":481},[181,4486,768],{"class":361},[181,4488,554],{"class":474},[181,4490,2648],{"class":361},[181,4492,4493],{"class":481},"()), content",[181,4495,757],{"class":474},[181,4497,4498],{"class":361}," String",[181,4500,554],{"class":474},[181,4502,2648],{"class":361},[181,4504,4505],{"class":481},"()})",[181,4507,1591],{"class":474},[181,4509,4049],{"class":481},[12,4511,4512,4513,4515,4516,4519,4520,4522],{},"このアプローチは、コードが複雑で読みにくく、さらにコード提案の支援がなかったため、手動でコーディングする必要があり、満足のいくものではありませんでした。一旦立ち止まり、アプローチを見直しました。",[160,4514,976],{}," が ",[160,4517,4518],{},"none"," の場合に",[160,4521,964],{}," はエラーをスローするのであれば、そのエラーを処理する簡単な方法があるのではと考え、コード提案に新しいコメントで質問しました。",[172,4524,4526],{"className":352,"code":4525,"language":354,"meta":177,"style":177},"\n                // xth attempt: Solution. Option::Some() requires a new String object.\n                println!(\"Summary: {}\", entry.summary.unwrap_or_else(|| Text{content_type: mime::TEXT_PLAIN, src: Option::Some(String::new()), content: String::new()}).content);\n\n                // Alternatively, use Option.is_none()\n\n",[160,4527,4528,4532,4566,4623,4627],{"__ignoreMap":177},[181,4529,4530],{"class":183,"line":184},[181,4531,188],{"emptyLinePlaceholder":187},[181,4533,4534,4537,4540,4543,4546,4549,4552,4555,4558,4561,4563],{"class":183,"line":191},[181,4535,4536],{"class":361},"                //",[181,4538,4539],{"class":365}," xth",[181,4541,4542],{"class":365}," attempt:",[181,4544,4545],{"class":365}," Solution.",[181,4547,4548],{"class":365}," Option::Some",[181,4550,4551],{"class":481},"() ",[181,4553,4554],{"class":365},"requires",[181,4556,4557],{"class":365}," a",[181,4559,4560],{"class":365}," new",[181,4562,4498],{"class":365},[181,4564,4565],{"class":365}," object.\n",[181,4567,4568,4571,4573,4575,4578,4580,4582,4584,4587,4590,4593,4595,4597,4600,4602,4604,4607,4610,4612,4615,4618,4621],{"class":183,"line":198},[181,4569,4570],{"class":361},"                println!(",[181,4572,4090],{"class":361},[181,4574,1669],{"class":361},[181,4576,4577],{"class":365}," entry.summary.unwrap_or_else",[181,4579,1124],{"class":481},[181,4581,2895],{"class":474},[181,4583,4456],{"class":361},[181,4585,4586],{"class":365},"{content_type:",[181,4588,4589],{"class":365}," mime::TEXT_PLAIN,",[181,4591,4592],{"class":365}," src:",[181,4594,4548],{"class":365},[181,4596,1124],{"class":481},[181,4598,4599],{"class":361},"String::new",[181,4601,1597],{"class":481},[181,4603,1669],{"class":365},[181,4605,4606],{"class":365}," content:",[181,4608,4609],{"class":365}," String::new",[181,4611,1898],{"class":481},[181,4613,4614],{"class":365},"}",[181,4616,4617],{"class":481},")",[181,4619,4620],{"class":365},".content",[181,4622,1940],{"class":481},[181,4624,4625],{"class":183,"line":204},[181,4626,188],{"emptyLinePlaceholder":187},[181,4628,4629,4631,4634,4637,4640],{"class":183,"line":210},[181,4630,4536],{"class":361},[181,4632,4633],{"class":365}," Alternatively,",[181,4635,4636],{"class":365}," use",[181,4638,4639],{"class":365}," Option.is_none",[181,4641,4642],{"class":481},"()\n",[12,4644,4645,231],{},[227,4646],{"alt":4647,"src":4648},"コード提案によるOptions.is_noneを使った代替案","https://res.cloudinary.com/about-gitlab-com/image/upload/v1782398608/blog/Content%20Images/learn-rust-with-ai-code-suggestions-advanced-programming/code_suggestions_after_complex_unwrap_or_else_ask_for_alternative_option.png",[12,4650,4651,4652,4654],{},"結果として、読みやすさが向上し、",[160,4653,964],{}," による無駄なCPUサイクルが減りました。複雑な問題を解決することから単純な解決策を使用することまでの学習過程を大幅に短縮できました。まさにウィンウィンです。",[12,4656,4657],{},"忘れないうちに、XMLデータをディスクに保存する指示を再度追加して、リーダーアプリを完成させましょう。",[172,4659,4661],{"className":174,"code":4660,"language":176,"meta":177,"style":177},"\n                // Dump the parsed body to a file, as name-current-iso-date.xml\n                let file_name = format!(\"{}-{}.xml\", thread_name, chrono::Local::now().format(\"%Y-%m-%d-%H-%M-%S\"));\n                let mut file = std::fs::File::create(file_name).unwrap();\n                file.write_all(body.as_ref()).unwrap();\n\n",[160,4662,4663,4667,4672,4715,4748],{"__ignoreMap":177},[181,4664,4665],{"class":183,"line":184},[181,4666,188],{"emptyLinePlaceholder":187},[181,4668,4669],{"class":183,"line":191},[181,4670,4671],{"class":194},"                // Dump the parsed body to a file, as name-current-iso-date.xml\n",[181,4673,4674,4677,4680,4682,4684,4686,4688,4691,4694,4696,4698,4700,4702,4704,4706,4708,4710,4713],{"class":183,"line":198},[181,4675,4676],{"class":474},"                let",[181,4678,4679],{"class":481}," file_name ",[181,4681,1572],{"class":474},[181,4683,2272],{"class":361},[181,4685,1124],{"class":481},[181,4687,2277],{"class":365},[181,4689,4690],{"class":481},", thread_name, ",[181,4692,4693],{"class":361},"chrono",[181,4695,554],{"class":474},[181,4697,2253],{"class":361},[181,4699,554],{"class":474},[181,4701,2258],{"class":361},[181,4703,1898],{"class":481},[181,4705,1591],{"class":474},[181,4707,2285],{"class":361},[181,4709,1124],{"class":481},[181,4711,4712],{"class":365},"\"%Y-%m-%d-%H-%M-%S\"",[181,4714,2293],{"class":481},[181,4716,4717,4719,4721,4723,4725,4727,4729,4731,4733,4735,4737,4739,4742,4744,4746],{"class":183,"line":204},[181,4718,4676],{"class":474},[181,4720,1919],{"class":474},[181,4722,2302],{"class":481},[181,4724,1572],{"class":474},[181,4726,551],{"class":361},[181,4728,554],{"class":474},[181,4730,2311],{"class":361},[181,4732,554],{"class":474},[181,4734,2316],{"class":361},[181,4736,554],{"class":474},[181,4738,2321],{"class":361},[181,4740,4741],{"class":481},"(file_name)",[181,4743,1591],{"class":474},[181,4745,1602],{"class":361},[181,4747,1605],{"class":481},[181,4749,4750,4753,4755,4757,4759,4761,4763,4765,4767,4769],{"class":183,"line":210},[181,4751,4752],{"class":481},"                file",[181,4754,1591],{"class":474},[181,4756,2340],{"class":361},[181,4758,1588],{"class":481},[181,4760,1591],{"class":474},[181,4762,3271],{"class":361},[181,4764,1597],{"class":481},[181,4766,1591],{"class":474},[181,4768,1602],{"class":361},[181,4770,1605],{"class":481},[12,4772,4773],{},"プログラムをビルドして実行し、出力を確認します。",[172,4775,4777],{"className":352,"code":4776,"language":354,"meta":177,"style":177},"cargo build\n\ntime cargo run -- \"GitLab Blog,https://about.gitlab.com/atom.xml\" \"CNCF,https://www.cncf.io/feed/\"\n",[160,4778,4779,4785,4789],{"__ignoreMap":177},[181,4780,4781,4783],{"class":183,"line":184},[181,4782,383],{"class":361},[181,4784,1332],{"class":365},[181,4786,4787],{"class":183,"line":191},[181,4788,188],{"emptyLinePlaceholder":187},[181,4790,4791,4793,4796,4799],{"class":183,"line":198},[181,4792,2414],{"class":474},[181,4794,4795],{"class":481}," cargo run -- ",[181,4797,4798],{"class":365},"\"GitLab Blog,https://about.gitlab.com/atom.xml\"",[181,4800,1803],{"class":365},[12,4802,4803],{},[227,4804],{"alt":4805,"src":304},"VS Codeターミナルでcargo runを実行し、フォーマットされたフィードエントリの出力",[137,4807,4808],{"id":4808},"ベンチマーク",[154,4810,121],{"id":121},[12,4812,4813],{},"それぞれ5つのサンプルを作成して、実行時間のベンチマークを比較します。",[282,4815,4816,4819],{},[40,4817,4818],{},"逐次実行",[40,4820,4821],{},"並列実行",[172,4823,4825],{"className":352,"code":4824,"language":354,"meta":177,"style":177},"# Sequential\ngit checkout sequential-exec\n\ntime cargo run -- \"GitLab Blog,https://about.gitlab.com/atom.xml\" \"CNCF,https://www.cncf.io/feed/\"\n\n0.21s user 0.08s system 10% cpu 2.898 total\n0.21s user 0.08s system 11% cpu 2.585 total\n0.21s user 0.09s system 10% cpu 2.946 total\n0.19s user 0.08s system 10% cpu 2.714 total\n0.20s user 0.10s system 10% cpu 2.808 total\n",[160,4826,4827,4832,4840,4844,4854,4858,4884,4904,4924,4944],{"__ignoreMap":177},[181,4828,4829],{"class":183,"line":184},[181,4830,4831],{"class":194},"# Sequential\n",[181,4833,4834,4836,4838],{"class":183,"line":191},[181,4835,396],{"class":361},[181,4837,2456],{"class":365},[181,4839,2462],{"class":365},[181,4841,4842],{"class":183,"line":198},[181,4843,188],{"emptyLinePlaceholder":187},[181,4845,4846,4848,4850,4852],{"class":183,"line":204},[181,4847,2414],{"class":474},[181,4849,4795],{"class":481},[181,4851,4798],{"class":365},[181,4853,1803],{"class":365},[181,4855,4856],{"class":183,"line":210},[181,4857,188],{"emptyLinePlaceholder":187},[181,4859,4860,4863,4866,4869,4872,4875,4878,4881],{"class":183,"line":393},[181,4861,4862],{"class":361},"0.21s",[181,4864,4865],{"class":365}," user",[181,4867,4868],{"class":365}," 0.08s",[181,4870,4871],{"class":365}," system",[181,4873,4874],{"class":365}," 10%",[181,4876,4877],{"class":365}," cpu",[181,4879,4880],{"class":371}," 2.898",[181,4882,4883],{"class":365}," total\n",[181,4885,4886,4888,4890,4892,4894,4897,4899,4902],{"class":183,"line":411},[181,4887,4862],{"class":361},[181,4889,4865],{"class":365},[181,4891,4868],{"class":365},[181,4893,4871],{"class":365},[181,4895,4896],{"class":365}," 11%",[181,4898,4877],{"class":365},[181,4900,4901],{"class":371}," 2.585",[181,4903,4883],{"class":365},[181,4905,4906,4908,4910,4913,4915,4917,4919,4922],{"class":183,"line":1991},[181,4907,4862],{"class":361},[181,4909,4865],{"class":365},[181,4911,4912],{"class":365}," 0.09s",[181,4914,4871],{"class":365},[181,4916,4874],{"class":365},[181,4918,4877],{"class":365},[181,4920,4921],{"class":371}," 2.946",[181,4923,4883],{"class":365},[181,4925,4926,4929,4931,4933,4935,4937,4939,4942],{"class":183,"line":1996},[181,4927,4928],{"class":361},"0.19s",[181,4930,4865],{"class":365},[181,4932,4868],{"class":365},[181,4934,4871],{"class":365},[181,4936,4874],{"class":365},[181,4938,4877],{"class":365},[181,4940,4941],{"class":371}," 2.714",[181,4943,4883],{"class":365},[181,4945,4946,4949,4951,4954,4956,4958,4960,4963],{"class":183,"line":2002},[181,4947,4948],{"class":361},"0.20s",[181,4950,4865],{"class":365},[181,4952,4953],{"class":365}," 0.10s",[181,4955,4871],{"class":365},[181,4957,4874],{"class":365},[181,4959,4877],{"class":365},[181,4961,4962],{"class":371}," 2.808",[181,4964,4883],{"class":365},[172,4966,4968],{"className":352,"code":4967,"language":354,"meta":177,"style":177},"# Parallel\ngit checkout parallel-exec\n\ntime cargo run -- \"GitLab Blog,https://about.gitlab.com/atom.xml\" \"CNCF,https://www.cncf.io/feed/\"\n\n0.19s user 0.08s system 17% cpu 1.515 total\n0.18s user 0.08s system 16% cpu 1.561 total\n0.18s user 0.07s system 17% cpu 1.414 total\n0.19s user 0.08s system 18% cpu 1.447 total\n0.17s user 0.08s system 16% cpu 1.453 total\n",[160,4969,4970,4975,4984,4988,4998,5002,5022,5043,5063,5083],{"__ignoreMap":177},[181,4971,4972],{"class":183,"line":184},[181,4973,4974],{"class":194},"# Parallel\n",[181,4976,4977,4979,4981],{"class":183,"line":191},[181,4978,396],{"class":361},[181,4980,2456],{"class":365},[181,4982,4983],{"class":365}," parallel-exec\n",[181,4985,4986],{"class":183,"line":198},[181,4987,188],{"emptyLinePlaceholder":187},[181,4989,4990,4992,4994,4996],{"class":183,"line":204},[181,4991,2414],{"class":474},[181,4993,4795],{"class":481},[181,4995,4798],{"class":365},[181,4997,1803],{"class":365},[181,4999,5000],{"class":183,"line":210},[181,5001,188],{"emptyLinePlaceholder":187},[181,5003,5004,5006,5008,5010,5012,5015,5017,5020],{"class":183,"line":393},[181,5005,4928],{"class":361},[181,5007,4865],{"class":365},[181,5009,4868],{"class":365},[181,5011,4871],{"class":365},[181,5013,5014],{"class":365}," 17%",[181,5016,4877],{"class":365},[181,5018,5019],{"class":371}," 1.515",[181,5021,4883],{"class":365},[181,5023,5024,5027,5029,5031,5033,5036,5038,5041],{"class":183,"line":411},[181,5025,5026],{"class":361},"0.18s",[181,5028,4865],{"class":365},[181,5030,4868],{"class":365},[181,5032,4871],{"class":365},[181,5034,5035],{"class":365}," 16%",[181,5037,4877],{"class":365},[181,5039,5040],{"class":371}," 1.561",[181,5042,4883],{"class":365},[181,5044,5045,5047,5049,5052,5054,5056,5058,5061],{"class":183,"line":1991},[181,5046,5026],{"class":361},[181,5048,4865],{"class":365},[181,5050,5051],{"class":365}," 0.07s",[181,5053,4871],{"class":365},[181,5055,5014],{"class":365},[181,5057,4877],{"class":365},[181,5059,5060],{"class":371}," 1.414",[181,5062,4883],{"class":365},[181,5064,5065,5067,5069,5071,5073,5076,5078,5081],{"class":183,"line":1996},[181,5066,4928],{"class":361},[181,5068,4865],{"class":365},[181,5070,4868],{"class":365},[181,5072,4871],{"class":365},[181,5074,5075],{"class":365}," 18%",[181,5077,4877],{"class":365},[181,5079,5080],{"class":371}," 1.447",[181,5082,4883],{"class":365},[181,5084,5085,5088,5090,5092,5094,5096,5098,5101],{"class":183,"line":2002},[181,5086,5087],{"class":361},"0.17s",[181,5089,4865],{"class":365},[181,5091,4868],{"class":365},[181,5093,4871],{"class":365},[181,5095,5035],{"class":365},[181,5097,4877],{"class":365},[181,5099,5100],{"class":371}," 1.453",[181,5102,4883],{"class":365},[12,5104,5105],{},"4つのRSSフィードスレッドを並列実行した場合、CPU使用率は増加しましたが、逐次実行に比べて全体の実行時間はほぼ半減しました。この点を踏まえて、Rustの学習を続け、コードと機能を最適化していきます。",[12,5107,5108],{},"なお、ここではCargoを使ってデバッグビルドを実行しており、最適化されたリリースビルドはまだ実行していません。また、並列実行にはいくつか注意点があります。一部のHTTPエンドポイントはレート制限を設けており、並列処理がこの制限に引っかかりやすくなる可能性があります。",[12,5110,5111,5112,5117],{},"複数のスレッドを並列実行するシステムも過負荷になる可能性があります。これは、カーネル内でのコンテキストスイッチ（スレッド間の切り替え）を通じて各スレッドにリソースを割り当てる必要があるためです。1つのスレッドが計算リソースを使用している間、他のスレッドは待機状態になります。スレッドが多すぎると、システム全体が遅くなり、処理がスピードアップするどころか逆に遅くなることもあります。解決策としては、呼び出し元がキューにタスクを追加し、定義された数のワーカースレッドが非同期実行のためにタスクを処理する",[16,5113,5116],{"href":5114,"rel":5115},"https://docs.rs/work-queue/latest/work_queue/",[],"ワークキュー","などの設計パターンがあります。",[12,5119,5120,5121,5126,5127,5132],{},"Rustでは、スレッド間のデータ同期を行う",[16,5122,5125],{"href":5123,"rel":5124},"https://doc.rust-lang.org/rust-by-example/std_misc/channels.html",[],"チャンネル","を利用することもできます。競合状態を防ぐために、セーフロックを提供する",[16,5128,5131],{"href":5129,"rel":5130},"https://doc.rust-lang.org/std/sync/struct.Mutex.html",[],"ミューテックス","も利用可能です。",[154,5134,124],{"id":5135},"rustのキャッシュを使用したcicd",[12,5137,5138,5139,5142,5143,5146,5147,5149],{},"以下のCI/CD構成を ",[160,5140,5141],{},".gitlab-ci.yml"," ファイルに追加します。この ",[160,5144,5145],{},"run-latest"," ジョブは ",[160,5148,1463],{}," をRSSフィードURLの例とともに呼び出し、実行時間を継続的に計測します。",[172,5151,5154],{"className":5152,"code":5153,"language":1056,"meta":177},[1054],"stages:\n  - build\n  - test\n  - run\n\ndefault:\n  image: rust:latest\n  cache:\n    key: ${CI_COMMIT_REF_SLUG}\n    paths:\n      - .cargo/bin\n      - .cargo/registry/index\n      - .cargo/registry/cache\n      - target/debug/deps\n      - target/debug/build\n    policy: pull-push\n\n# Cargo data needs to be in the project directory for being cached.\nvariables:\n  CARGO_HOME: ${CI_PROJECT_DIR}/.cargo\n\nbuild-latest:\n  stage: build\n  script:\n    - cargo build --verbose\n\ntest-latest:\n  stage: build\n  script:\n    - cargo test --verbose\n\nrun-latest:\n  stage: run\n  script:\n    - time cargo run -- \"GitLab Blog,https://about.gitlab.com/atom.xml\" \"CNCF,https://www.cncf.io/feed/\"\n\n",[160,5155,5153],{"__ignoreMap":177},[12,5157,5158,231],{},[227,5159],{"alt":5160,"src":5161},"Rust用のGitLab CI/CDパイプライン、cargo runの出力","https://res.cloudinary.com/about-gitlab-com/image/upload/v1782398626/blog/Content%20Images/learn-rust-with-ai-code-suggestions-advanced-programming/gitlab_cicd_pipeline_rust_cargo_run_output.png",[137,5163,5164],{"id":5164},"次のステップ",[12,5166,5167],{},"このブログ記事の執筆は、筆者自身が高度なRustプログラミング技術を学びつつ、コード提案を使って最適な学習過程を見出すという点で難しいものでした。コード提案は、単なる定型的なコードだけでなく、ローカルコンテキストを理解し、記述されたコードが多いほどアルゴリズムの目的や範囲をよりよく把握した迅速なコード生成にも大いに役立ちます。このブログ記事を読むことで、全てではないにしろ、いくつかの課題や解決策についてご理解いただけたかと思います。",[12,5169,5170,5171,5174,5175,5182],{},"RSSフィードの解析は、外部HTTPリクエストや並列最適化を伴うデータ構造が関わるため、ハードルが高めです。経験豊富なRustユーザーであれば、",[160,5172,5173],{},"なぜstd::rssクレートを使わなかったのか？"," と疑問に思うかもしれません。その理由は、std::rssは高度な非同期実行に最適化されており、このブログ記事でご説明したさまざまなRustの機能を示したり説明したりすることができないためです。ぜひ、非同期の演習として、",[16,5176,5179,5181],{"href":5177,"rel":5178},"https://docs.rs/rss/latest/rss/",[],[160,5180,3422],{}," クレート","を使ってコードを書き直してみてください。",[154,5184,5185],{"id":5185},"非同期学習のエクササイズ",[12,5187,5188],{},"このブログ記事で学んだ内容は、永続的なデータ保存やデータ表示に関する理解を今後も深めていく上で基礎となります。引き続きRustを学びながら、リーダーアプリを最適化していくためのアイデアをいくつかご紹介します。",[282,5190,5191,5194,5197,5200,5203,5206],{},[40,5192,5193],{},"データ保存：sqliteなどのデータベースを使用し、RSSフィードの更新履歴を追跡する。",[40,5195,5196],{},"通知：子プロセスを生成して、Telegramなどに通知を送る機能を追加する。",[40,5198,5199],{},"機能：リーダータイプを拡張して、REST APIをサポートする。",[40,5201,5202],{},"構成：RSSフィードやAPIなどの構成ファイルのサポートを追加する。",[40,5204,5205],{},"効率性：フィルタリングやサブスクライブしたタグのサポートを追加する。",[40,5207,5208,5209,5214],{},"デプロイ：Webサーバーを使用して、Prometheusメトリクスを収集して",[16,5210,5213],{"href":5211,"rel":5212},"https://about.gitlab.com/ja-jp/blog/what-is-kubernetes/",[],"Kubernetes","にデプロイする。",[12,5216,5217,5218,5221],{},"今後のブログ記事では、これらのアイデアのいくつかを取り上げ、その実装方法について説明します。既存のRSSフィードの実装を詳しく調べ、どのように既存のコードをリファクタリングしてRustのライブラリ（",[160,5219,5220],{},"crates","）を活用できるか学びましょう。",[154,5223,135],{"id":135},[12,5225,5226,5230,5231,5236],{},[16,5227,5229],{"href":24,"rel":5228},[],"GitLab Duo","のコード提案をご使用になった方は、ぜひ",[16,5232,5235],{"href":5233,"rel":5234},"https://gitlab.com/gitlab-org/gitlab/-/issues/405152",[],"ご意見をフィードバックイシューにお寄せください","。",[12,5238,5239],{},[5240,5241,5242,5243,5248,5249,5252],"em",{},"監修：佐々木 直晴 ",[16,5244,5247],{"href":5245,"rel":5246},"https://gitlab.com/naosasaki",[],"@naosasaki"," ",[5250,5251],"br",{},"\n（GitLab合同会社 ソリューションアーキテクト本部 シニアソリューションアーキテクト）",[5254,5255,5256],"style",{},"html pre.shiki code .sAwPA, html code.shiki .sAwPA{--shiki-default:#6A737D}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .s7eDp, html code.shiki .s7eDp{--shiki-default:#6F42C1}html pre.shiki code .sYBdl, html code.shiki .sYBdl{--shiki-default:#032F62}html pre.shiki code .sYu0t, html code.shiki .sYu0t{--shiki-default:#005CC5}html pre.shiki code .sD7c4, html code.shiki .sD7c4{--shiki-default:#D73A49}html pre.shiki code .sgsFI, html code.shiki .sgsFI{--shiki-default:#24292E}html pre.shiki code .shJU0, html code.shiki .shJU0{--shiki-default:#22863A}",{"title":177,"searchDepth":191,"depth":191,"links":5258},[5259,5262,5267,5270,5273,5276,5277,5282,5286,5290],{"id":139,"depth":191,"text":139,"children":5260},[5261],{"id":47,"depth":198,"text":47},{"id":234,"depth":191,"text":235,"children":5263},[5264,5265,5266],{"id":259,"depth":198,"text":55},{"id":58,"depth":198,"text":58},{"id":445,"depth":198,"text":61},{"id":624,"depth":191,"text":624,"children":5268},[5269],{"id":1025,"depth":198,"text":69},{"id":1476,"depth":191,"text":1476,"children":5271},[5272],{"id":1531,"depth":198,"text":77},{"id":1628,"depth":191,"text":1629,"children":5274},[5275],{"id":85,"depth":198,"text":85},{"id":88,"depth":191,"text":88},{"id":2392,"depth":191,"text":2392,"children":5278},[5279,5280,5281],{"id":96,"depth":198,"text":96},{"id":99,"depth":198,"text":99},{"id":2867,"depth":198,"text":102},{"id":3149,"depth":191,"text":3150,"children":5283},[5284,5285],{"id":110,"depth":198,"text":110},{"id":4205,"depth":198,"text":113},{"id":4808,"depth":191,"text":4808,"children":5287},[5288,5289],{"id":121,"depth":198,"text":121},{"id":5135,"depth":198,"text":124},{"id":5164,"depth":191,"text":5164,"children":5291},[5292,5293],{"id":5185,"depth":198,"text":5185},{"id":135,"depth":198,"text":135},"ai","2023-10-12","このガイド付きチュートリアルでは、AIを搭載したGitLab Duoのコード提案を活用しながら、Rustの高度なプログラミングを学ぶことができます。","md",null,false,"https://res.cloudinary.com/about-gitlab-com/image/upload/v1749662439/Blog/Hero%20Images/codewithheart.png",{},"/ja-jp/blog/learn-advanced-rust-programming-with-a-little-help-from-ai-code-suggestions",{"title":5,"description":5296,"ogTitle":5,"ogDescription":5296,"noIndex":5299,"ogImage":5300,"ogUrl":5304,"ogSiteName":5305,"ogType":5306,"canonicalUrls":5304},"https://about.gitlab.com/blog/learn-advanced-rust-programming-with-a-little-help-from-ai-code-suggestions","https://about.gitlab.com","article","learn-advanced-rust-programming-with-a-little-help-from-ai-code-suggestions","ja-jp/blog/learn-advanced-rust-programming-with-a-little-help-from-ai-code-suggestions",[5310,5311,5312,5313,5314],"DevSecOps","careers","tutorial","workflow","AI","BlogPost","2025-01-24","vIOwe5Ct_ieXC7PeXSNxFLMJ-0KvXyzy2avh-2ar0XU",{"logo":5319,"freeTrial":5324,"sales":5329,"login":5334,"items":5339,"search":5668,"minimal":5701,"duo":5718,"switchNav":5727,"pricingDeployment":5738},{"config":5320},{"href":5321,"dataGaName":5322,"dataGaLocation":5323},"/ja-jp/","gitlab logo","header",{"text":5325,"config":5326},"無料トライアルを開始",{"href":5327,"dataGaName":5328,"dataGaLocation":5323},"https://gitlab.com/-/trial_registrations/new?glm_source=about.gitlab.com/ja-jp&glm_content=default-saas-trial/","free trial",{"text":5330,"config":5331},"デモをリクエスト",{"href":5332,"dataGaName":5333,"dataGaLocation":5323},"/ja-jp/sales/?contact-topic=request-demo","sales",{"text":5335,"config":5336},"サインイン",{"href":5337,"dataGaName":5338,"dataGaLocation":5323},"https://gitlab.com/users/sign_in/","sign in",[5340,5369,5471,5476,5590,5646],{"text":5341,"config":5342,"menu":5344},"プラットフォーム",{"dataNavLevelOne":5343},"platform",{"type":5345,"columns":5346},"cards",[5347,5353,5361],{"title":5341,"description":5348,"link":5349},"DevSecOpsに特化したインテリジェントオーケストレーションプラットフォーム",{"text":5350,"config":5351},"プラットフォームの詳細はこちら",{"href":5352,"dataGaName":5343,"dataGaLocation":5323},"/ja-jp/platform/",{"title":5354,"description":5355,"link":5356},"GitLab Duo Agent Platform","ソフトウェアライフサイクル全体を支えるエージェント型AI",{"text":5357,"config":5358},"GitLab Duoのご紹介",{"href":5359,"dataGaName":5360,"dataGaLocation":5323},"/ja-jp/gitlab-duo-agent-platform/","gitlab duo agent platform",{"title":5362,"description":5363,"link":5364},"GitLabが選ばれる理由","エンタープライズがGitLabを選ぶ主な理由をご覧ください",{"text":5365,"config":5366},"詳細はこちら",{"href":5367,"dataGaName":5368,"dataGaLocation":5323},"/ja-jp/why-gitlab/","why gitlab",{"text":5370,"left":187,"config":5371,"menu":5373},"製品",{"dataNavLevelOne":5372},"solutions",{"type":5374,"link":5375,"columns":5379,"feature":5450},"lists",{"text":5376,"config":5377},"すべてのソリューションを表示",{"href":5378,"dataGaName":5372,"dataGaLocation":5323},"/ja-jp/solutions/",[5380,5405,5428],{"title":5381,"description":5382,"link":5383,"items":5388},"自動化","CI/CDと自動化でデプロイを加速",{"config":5384},{"icon":5385,"href":5386,"dataGaName":5387,"dataGaLocation":5323},"AutomatedCodeAlt","/ja-jp/solutions/delivery-automation/","automated software delivery",[5389,5393,5396,5401],{"text":5390,"config":5391},"CI/CD",{"href":5392,"dataGaLocation":5323,"dataGaName":5390},"/ja-jp/solutions/continuous-integration/",{"text":5354,"config":5394},{"href":5359,"dataGaLocation":5323,"dataGaName":5395},"gitlab duo agent platform - product menu",{"text":5397,"config":5398},"ソースコード管理",{"href":5399,"dataGaLocation":5323,"dataGaName":5400},"/ja-jp/solutions/source-code-management/","Source Code Management",{"text":5402,"config":5403},"自動化されたソフトウェアデリバリー",{"href":5386,"dataGaLocation":5323,"dataGaName":5404},"Automated software delivery",{"title":5406,"description":5407,"link":5408,"items":5413},"セキュリティ","セキュリティを犠牲にすることなくコード作成を高速化",{"config":5409},{"href":5410,"dataGaName":5411,"dataGaLocation":5323,"icon":5412},"/ja-jp/solutions/application-security-testing/","security and compliance","ShieldCheckLight",[5414,5418,5423],{"text":5415,"config":5416},"アプリケーションセキュリティテスト",{"href":5410,"dataGaName":5417,"dataGaLocation":5323},"Application security testing",{"text":5419,"config":5420},"ソフトウェアサプライチェーンセキュリティ",{"href":5421,"dataGaLocation":5323,"dataGaName":5422},"/ja-jp/solutions/supply-chain/","Software supply chain security",{"text":5424,"config":5425},"ソフトウェアコンプライアンス",{"href":5426,"dataGaName":5427,"dataGaLocation":5323},"/ja-jp/solutions/software-compliance/","software compliance",{"title":5429,"link":5430,"items":5435},"測定",{"config":5431},{"icon":5432,"href":5433,"dataGaName":5434,"dataGaLocation":5323},"DigitalTransformation","/ja-jp/solutions/visibility-measurement/","visibility and measurement",[5436,5440,5445],{"text":5437,"config":5438},"可視性と測定",{"href":5433,"dataGaLocation":5323,"dataGaName":5439},"Visibility and Measurement",{"text":5441,"config":5442},"バリューストリーム管理",{"href":5443,"dataGaLocation":5323,"dataGaName":5444},"/ja-jp/solutions/value-stream-management/","Value Stream Management",{"text":5446,"config":5447},"分析とインサイト",{"href":5448,"dataGaLocation":5323,"dataGaName":5449},"/ja-jp/solutions/analytics-and-insights/","Analytics and insights",{"title":5451,"type":5374,"items":5452},"GitLabが活躍する場所",[5453,5459,5465],{"text":5454,"config":5455},"大企業",{"icon":5456,"href":5457,"dataGaLocation":5323,"dataGaName":5458},"Building","/ja-jp/enterprise/","enterprise",{"text":5460,"config":5461},"スモールビジネス",{"icon":5462,"href":5463,"dataGaLocation":5323,"dataGaName":5464},"Work","/ja-jp/small-business/","small business",{"text":5466,"config":5467},"公共部門",{"icon":5468,"href":5469,"dataGaLocation":5323,"dataGaName":5470},"Organization","/ja-jp/solutions/public-sector/","public sector",{"text":5472,"config":5473},"価格",{"href":5474,"dataGaName":5475,"dataGaLocation":5323,"dataNavLevelOne":5475},"/ja-jp/pricing/","pricing",{"text":5477,"config":5478,"menu":5480},"関連リソース",{"dataNavLevelOne":5479},"resources",{"type":5374,"link":5481,"columns":5485,"feature":5579},{"text":5482,"config":5483},"すべてのリソースを表示",{"href":5484,"dataGaName":5479,"dataGaLocation":5323},"/ja-jp/resources/",[5486,5519,5546],{"title":5487,"items":5488},"はじめに",[5489,5494,5499,5504,5509,5514],{"text":5490,"config":5491},"インストール",{"href":5492,"dataGaName":5493,"dataGaLocation":5323},"/ja-jp/install/","install",{"text":5495,"config":5496},"クイックスタートガイド",{"href":5497,"dataGaName":5498,"dataGaLocation":5323},"/ja-jp/get-started/","quick setup checklists",{"text":5500,"config":5501},"学ぶ",{"href":5502,"dataGaLocation":5323,"dataGaName":5503},"https://university.gitlab.com/","learn",{"text":5505,"config":5506},"製品ドキュメント",{"href":5507,"dataGaName":5508,"dataGaLocation":5323},"https://docs.gitlab.com/ja-jp/","product documentation",{"text":5510,"config":5511},"ベストプラクティスビデオ",{"href":5512,"dataGaName":5513,"dataGaLocation":5323},"/ja-jp/getting-started-videos/","best practice videos",{"text":5515,"config":5516},"インテグレーション",{"href":5517,"dataGaName":5518,"dataGaLocation":5323},"/ja-jp/integrations/","integrations",{"title":5520,"items":5521},"検索する",[5522,5527,5532,5537,5541],{"text":5523,"config":5524},"お客様成功事例",{"href":5525,"dataGaName":5526,"dataGaLocation":5323},"/ja-jp/customers/","customer success stories",{"text":5528,"config":5529},"ブログ",{"href":5530,"dataGaName":5531,"dataGaLocation":5323},"/ja-jp/blog/","blog",{"text":5533,"config":5534},"Demo Hub",{"href":5535,"dataGaName":5536,"dataGaLocation":5323},"/ja-jp/demo-hub/","demo hub",{"text":5538,"config":5539},"The Source",{"href":5540,"dataGaName":5531,"dataGaLocation":5323},"/ja-jp/the-source/",{"text":5542,"config":5543},"リモート",{"href":5544,"dataGaName":5545,"dataGaLocation":5323},"https://handbook.gitlab.com/handbook/company/culture/all-remote/","remote",{"title":5547,"items":5548},"つなげる",[5549,5554,5559,5564,5569,5574],{"text":5550,"config":5551},"GitLabサービス",{"href":5552,"dataGaName":5553,"dataGaLocation":5323},"/ja-jp/services/","services",{"text":5555,"config":5556},"コントリビュート",{"href":5557,"dataGaName":5558,"dataGaLocation":5323},"https://contributors.gitlab.com","contribute",{"text":5560,"config":5561},"コミュニティ",{"href":5562,"dataGaName":5563,"dataGaLocation":5323},"/community/","community",{"text":5565,"config":5566},"フォーラム",{"href":5567,"dataGaName":5568,"dataGaLocation":5323},"https://forum.gitlab.com/","forum",{"text":5570,"config":5571},"イベント",{"href":5572,"dataGaName":5573,"dataGaLocation":5323},"/events/","events",{"text":5575,"config":5576},"パートナー",{"href":5577,"dataGaName":5578,"dataGaLocation":5323},"/ja-jp/partners/","partners",{"config":5580,"title":5583,"text":5584,"link":5585},{"background":5581,"textColor":5582},"url('https://res.cloudinary.com/about-gitlab-com/image/upload/v1777322348/qpq8yrgn8knii57omj0c.png')","#000","GitLabの最新情報","最新の機能と改善点に関する情報をお届けします。",{"text":5586,"config":5587},"最新情報を読む",{"href":5588,"dataGaName":5589,"dataGaLocation":5323},"/ja-jp/whats-new/","whats new",{"text":5591,"config":5592,"menu":5594},"企業情報",{"dataNavLevelOne":5593},"company",{"type":5374,"columns":5595},[5596],{"items":5597},[5598,5603,5609,5611,5616,5621,5626,5631,5636,5641],{"text":5599,"config":5600},"GitLabについて",{"href":5601,"dataGaName":5602,"dataGaLocation":5323},"/ja-jp/company/","about",{"text":5604,"config":5605,"footerGa":5608},"採用情報",{"href":5606,"dataGaName":5607,"dataGaLocation":5323},"/jobs/","jobs",{"dataGaName":5607},{"text":5570,"config":5610},{"href":5572,"dataGaName":5573,"dataGaLocation":5323},{"text":5612,"config":5613},"経営陣",{"href":5614,"dataGaName":5615,"dataGaLocation":5323},"/company/team/e-group/","leadership",{"text":5617,"config":5618},"ハンドブック",{"href":5619,"dataGaName":5620,"dataGaLocation":5323},"https://handbook.gitlab.com/","handbook",{"text":5622,"config":5623},"投資家向け情報",{"href":5624,"dataGaName":5625,"dataGaLocation":5323},"https://ir.gitlab.com/overview/default.aspx","investor relations",{"text":5627,"config":5628},"トラストセンター",{"href":5629,"dataGaName":5630,"dataGaLocation":5323},"/ja-jp/security/","trust center",{"text":5632,"config":5633},"AI Transparency Center",{"href":5634,"dataGaName":5635,"dataGaLocation":5323},"/ja-jp/ai-transparency-center/","ai transparency center",{"text":5637,"config":5638},"ニュースレター",{"href":5639,"dataGaName":5640,"dataGaLocation":5323},"/company/contact/#contact-forms","newsletter",{"text":5642,"config":5643},"プレス",{"href":5644,"dataGaName":5645,"dataGaLocation":5323},"/press/","press",{"text":5647,"config":5648,"menu":5649},"お問い合わせ",{"dataNavLevelOne":5593},{"type":5374,"columns":5650},[5651],{"items":5652},[5653,5658,5663],{"text":5654,"config":5655},"お問い合わせはこちら",{"href":5656,"dataGaName":5657,"dataGaLocation":5323},"/ja-jp/sales/","talk to sales",{"text":5659,"config":5660},"サポートを受ける",{"href":5661,"dataGaName":5662,"dataGaLocation":5323},"https://support.gitlab.com/hc/en-us","support portal",{"text":5664,"config":5665},"カスタマーポータル",{"href":5666,"dataGaName":5667,"dataGaLocation":5323},"https://customers.gitlab.com/customers/sign_in/","customer portal",{"close":5669,"login":5670,"suggestions":5677},"閉じる",{"text":5671,"link":5672},"リポジトリとプロジェクトを検索するには、次にログインします",{"text":5673,"config":5674},"GitLab.com",{"href":5337,"dataGaName":5675,"dataGaLocation":5676},"search login","search",{"text":5678,"default":5679},"提案",[5680,5682,5687,5689,5693,5697],{"text":5354,"config":5681},{"href":5359,"dataGaName":5354,"dataGaLocation":5676},{"text":5683,"config":5684},"コード提案（AI）",{"href":5685,"dataGaName":5686,"dataGaLocation":5676},"/ja-jp/solutions/code-suggestions/","Code Suggestions (AI)",{"text":5390,"config":5688},{"href":5392,"dataGaName":5390,"dataGaLocation":5676},{"text":5690,"config":5691},"GitLab on AWS",{"href":5692,"dataGaName":5690,"dataGaLocation":5676},"/ja-jp/partners/technology-partners/aws/",{"text":5694,"config":5695},"GitLab on Google Cloud",{"href":5696,"dataGaName":5694,"dataGaLocation":5676},"/ja-jp/partners/technology-partners/google-cloud-platform/",{"text":5698,"config":5699},"GitLabを選ぶ理由",{"href":5367,"dataGaName":5700,"dataGaLocation":5676},"Why GitLab?",{"freeTrial":5702,"mobileIcon":5706,"desktopIcon":5711,"secondaryButton":5714},{"text":5325,"config":5703},{"href":5704,"dataGaName":5328,"dataGaLocation":5705},"https://gitlab.com/-/trials/new/","nav",{"altText":5707,"config":5708},"GitLabアイコン",{"src":5709,"dataGaName":5710,"dataGaLocation":5705},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1758203874/jypbw1jx72aexsoohd7x.svg","gitlab icon",{"altText":5707,"config":5712},{"src":5713,"dataGaName":5710,"dataGaLocation":5705},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1758203875/gs4c8p8opsgvflgkswz9.svg",{"text":5487,"config":5715},{"href":5716,"dataGaName":5717,"dataGaLocation":5705},"https://gitlab.com/-/trial_registrations/new?glm_source=about.gitlab.com/ja-jp/get-started/","get started",{"freeTrial":5719,"mobileIcon":5723,"desktopIcon":5725},{"text":5720,"config":5721},"GitLab Duoの詳細について",{"href":5359,"dataGaName":5722,"dataGaLocation":5705},"gitlab duo",{"altText":5707,"config":5724},{"src":5709,"dataGaName":5710,"dataGaLocation":5705},{"altText":5707,"config":5726},{"src":5713,"dataGaName":5710,"dataGaLocation":5705},{"button":5728,"mobileIcon":5733,"desktopIcon":5735},{"text":5729,"config":5730},"/switch",{"href":5731,"dataGaName":5732,"dataGaLocation":5705},"#contact","switch",{"altText":5707,"config":5734},{"src":5709,"dataGaName":5710,"dataGaLocation":5705},{"altText":5707,"config":5736},{"src":5737,"dataGaName":5710,"dataGaLocation":5705},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1773335277/ohhpiuoxoldryzrnhfrh.png",{"freeTrial":5739,"mobileIcon":5744,"desktopIcon":5746},{"text":5740,"config":5741},"料金ページに戻る",{"href":5474,"dataGaName":5742,"dataGaLocation":5705,"icon":5743},"back to pricing","GoBack",{"altText":5707,"config":5745},{"src":5709,"dataGaName":5710,"dataGaLocation":5705},{"altText":5707,"config":5747},{"src":5713,"dataGaName":5710,"dataGaLocation":5705},{"title":5749,"button":5750,"config":5754},"GitLab Orbitが登場: AIエージェントのためのコンテキストレイヤー",{"text":5365,"config":5751},{"href":5752,"dataGaName":5753,"dataGaLocation":5323},"/ja-jp/gitlab-orbit/","orbit",{"layout":5755,"disabled":5299},"release",{"data":5757},{"text":5758,"source":5759,"edit":5765,"contribute":5770,"config":5775,"items":5780,"minimal":5988},"GitはSoftware Freedom Conservancyの商標です。当社は「GitLab」をライセンスに基づいて使用しています",{"text":5760,"config":5761},"ページのソースを表示",{"href":5762,"dataGaName":5763,"dataGaLocation":5764},"https://gitlab.com/gitlab-com/marketing/digital-experience/about-gitlab-com/","page source","footer",{"text":5766,"config":5767},"このページを編集",{"href":5768,"dataGaName":5769,"dataGaLocation":5764},"https://gitlab.com/gitlab-com/marketing/digital-experience/about-gitlab-com/-/blob/main/content/","web ide",{"text":5771,"config":5772},"ご協力をお願いします",{"href":5773,"dataGaName":5774,"dataGaLocation":5764},"https://gitlab.com/gitlab-com/marketing/digital-experience/about-gitlab-com/-/blob/main/CONTRIBUTING.md/","please contribute",{"twitter":5776,"facebook":5777,"youtube":5778,"linkedin":5779},"https://twitter.com/gitlab","https://www.facebook.com/gitlab","https://www.youtube.com/channel/UCnMGQ8QHMAnVIsI3xJrihhg","https://www.linkedin.com/company/gitlab-com",[5781,5826,5878,5921,5955],{"title":5472,"links":5782,"subMenu":5797},[5783,5787,5792],{"text":5784,"config":5785},"プランの表示",{"href":5474,"dataGaName":5786,"dataGaLocation":5764},"view plans",{"text":5788,"config":5789},"Premiumを選ぶ理由",{"href":5790,"dataGaName":5791,"dataGaLocation":5764},"/ja-jp/pricing/premium/","why premium",{"text":5793,"config":5794},"Ultimateを選ぶ理由",{"href":5795,"dataGaName":5796,"dataGaLocation":5764},"/ja-jp/pricing/ultimate/","why ultimate",[5798],{"title":5647,"links":5799},[5800,5802,5804,5806,5811,5816,5821],{"text":5647,"config":5801},{"href":5656,"dataGaName":5333,"dataGaLocation":5764},{"text":5659,"config":5803},{"href":5661,"dataGaName":5662,"dataGaLocation":5764},{"text":5664,"config":5805},{"href":5666,"dataGaName":5667,"dataGaLocation":5764},{"text":5807,"config":5808},"ステータス",{"href":5809,"dataGaName":5810,"dataGaLocation":5764},"https://status.gitlab.com/","status",{"text":5812,"config":5813},"利用規約",{"href":5814,"dataGaName":5815,"dataGaLocation":5764},"/terms/","terms of use",{"text":5817,"config":5818},"プライバシーに関する声明",{"href":5819,"dataGaName":5820,"dataGaLocation":5764},"/ja-jp/privacy/","privacy statement",{"text":5822,"config":5823},"Cookie 優先設定",{"dataGaName":5824,"dataGaLocation":5764,"id":5825,"isOneTrustButton":187},"cookie preferences","ot-sdk-btn",{"title":5370,"links":5827,"subMenu":5836},[5828,5832],{"text":5829,"config":5830},"DevSecOpsプラットフォーム",{"href":5352,"dataGaName":5831,"dataGaLocation":5764},"devsecops platform",{"text":5833,"config":5834},"AI支援開発",{"href":5359,"dataGaName":5835,"dataGaLocation":5764},"ai-assisted development",[5837],{"title":5838,"links":5839},"トピック",[5840,5844,5849,5854,5859,5863,5868,5873],{"text":5390,"config":5841},{"href":5842,"dataGaName":5843,"dataGaLocation":5764},"/ja-jp/topics/ci-cd/","cicd",{"text":5845,"config":5846},"GitOps",{"href":5847,"dataGaName":5848,"dataGaLocation":5764},"/ja-jp/topics/gitops/","gitops",{"text":5850,"config":5851},"DevOps",{"href":5852,"dataGaName":5853,"dataGaLocation":5764},"/ja-jp/topics/devops/","devops",{"text":5855,"config":5856},"バージョン管理",{"href":5857,"dataGaName":5858,"dataGaLocation":5764},"/ja-jp/topics/version-control/","version control",{"text":5310,"config":5860},{"href":5861,"dataGaName":5862,"dataGaLocation":5764},"/ja-jp/topics/devsecops/","devsecops",{"text":5864,"config":5865},"クラウドネイティブ",{"href":5866,"dataGaName":5867,"dataGaLocation":5764},"/ja-jp/topics/cloud-native/","cloud native",{"text":5869,"config":5870},"コーディングのためのAI",{"href":5871,"dataGaName":5872,"dataGaLocation":5764},"/ja-jp/topics/devops/ai-for-coding/","ai for coding",{"text":5874,"config":5875},"エージェント型AI",{"href":5876,"dataGaName":5877,"dataGaLocation":5764},"/ja-jp/topics/agentic-ai/","agentic ai",{"title":5879,"links":5880},"ソリューション",[5881,5884,5886,5891,5895,5898,5901,5904,5906,5908,5911,5916],{"text":5415,"config":5882},{"href":5410,"dataGaName":5883,"dataGaLocation":5764},"Application Security Testing",{"text":5402,"config":5885},{"href":5386,"dataGaName":5387,"dataGaLocation":5764},{"text":5887,"config":5888},"アジャイル開発",{"href":5889,"dataGaName":5890,"dataGaLocation":5764},"/ja-jp/solutions/agile-delivery/","agile delivery",{"text":5892,"config":5893},"SCM",{"href":5399,"dataGaName":5894,"dataGaLocation":5764},"source code management",{"text":5390,"config":5896},{"href":5392,"dataGaName":5897,"dataGaLocation":5764},"continuous integration & delivery",{"text":5441,"config":5899},{"href":5443,"dataGaName":5900,"dataGaLocation":5764},"value stream management",{"text":5845,"config":5902},{"href":5903,"dataGaName":5848,"dataGaLocation":5764},"/ja-jp/solutions/gitops/",{"text":5454,"config":5905},{"href":5457,"dataGaName":5458,"dataGaLocation":5764},{"text":5460,"config":5907},{"href":5463,"dataGaName":5464,"dataGaLocation":5764},{"text":5909,"config":5910},"公共機関",{"href":5469,"dataGaName":5470,"dataGaLocation":5764},{"text":5912,"config":5913},"教育",{"href":5914,"dataGaName":5915,"dataGaLocation":5764},"/ja-jp/solutions/education/","education",{"text":5917,"config":5918},"金融サービス",{"href":5919,"dataGaName":5920,"dataGaLocation":5764},"/ja-jp/solutions/finance/","financial services",{"title":5922,"links":5923},"リソース",[5924,5926,5928,5930,5934,5936,5939,5941,5943,5945,5947,5949,5951,5953],{"text":5490,"config":5925},{"href":5492,"dataGaName":5493,"dataGaLocation":5764},{"text":5495,"config":5927},{"href":5497,"dataGaName":5498,"dataGaLocation":5764},{"text":5500,"config":5929},{"href":5502,"dataGaName":5503,"dataGaLocation":5764},{"text":5505,"config":5931},{"href":5932,"dataGaName":5933,"dataGaLocation":5764},"https://docs.gitlab.com/ja-jp","docs",{"text":5528,"config":5935},{"href":5530,"dataGaName":5531,"dataGaLocation":5764},{"text":5937,"config":5938},"最新リリース",{"href":5588,"dataGaName":5589,"dataGaLocation":5764},{"text":5523,"config":5940},{"href":5525,"dataGaName":5526,"dataGaLocation":5764},{"text":5542,"config":5942},{"href":5544,"dataGaName":5545,"dataGaLocation":5764},{"text":5550,"config":5944},{"href":5552,"dataGaName":5553,"dataGaLocation":5764},{"text":5555,"config":5946},{"href":5557,"dataGaName":5558,"dataGaLocation":5764},{"text":5560,"config":5948},{"href":5562,"dataGaName":5563,"dataGaLocation":5764},{"text":5565,"config":5950},{"href":5567,"dataGaName":5568,"dataGaLocation":5764},{"text":5570,"config":5952},{"href":5572,"dataGaName":5573,"dataGaLocation":5764},{"text":5575,"config":5954},{"href":5577,"dataGaName":5578,"dataGaLocation":5764},{"title":5956,"links":5957},"会社情報",[5958,5960,5962,5964,5966,5968,5972,5977,5979,5981,5983],{"text":5599,"config":5959},{"href":5601,"dataGaName":5593,"dataGaLocation":5764},{"text":5604,"config":5961},{"href":5606,"dataGaName":5607,"dataGaLocation":5764},{"text":5612,"config":5963},{"href":5614,"dataGaName":5615,"dataGaLocation":5764},{"text":5617,"config":5965},{"href":5619,"dataGaName":5620,"dataGaLocation":5764},{"text":5622,"config":5967},{"href":5624,"dataGaName":5625,"dataGaLocation":5764},{"text":5969,"config":5970},"Sustainability",{"href":5971,"dataGaName":5969,"dataGaLocation":5764},"/sustainability/",{"text":5973,"config":5974},"ダイバーシティ、インクルージョン、ビロンギング（DIB）",{"href":5975,"dataGaName":5976,"dataGaLocation":5764},"/ja-jp/diversity-inclusion-belonging/","Diversity, inclusion and belonging",{"text":5627,"config":5978},{"href":5629,"dataGaName":5630,"dataGaLocation":5764},{"text":5637,"config":5980},{"href":5639,"dataGaName":5640,"dataGaLocation":5764},{"text":5642,"config":5982},{"href":5644,"dataGaName":5645,"dataGaLocation":5764},{"text":5984,"config":5985},"現代奴隷制の透明性に関する声明",{"href":5986,"dataGaName":5987,"dataGaLocation":5764},"https://handbook.gitlab.com/handbook/legal/modern-slavery-act-transparency-statement/","modern slavery transparency statement",{"items":5989},[5990,5992,5995],{"text":5812,"config":5991},{"href":5814,"dataGaName":5815,"dataGaLocation":5764},{"text":5993,"config":5994},"Cookieの設定",{"dataGaName":5824,"dataGaLocation":5764,"id":5825,"isOneTrustButton":187},{"text":5817,"config":5996},{"href":5819,"dataGaName":5820,"dataGaLocation":5764},[5998],{"id":5999,"title":7,"body":5298,"config":6000,"content":6002,"description":5298,"extension":6006,"meta":6007,"navigation":187,"path":6008,"seo":6009,"stem":6010,"__hash__":6011},"blogAuthors/en-us/blog/authors/michael-friedrich.yml",{"template":6001},"BlogAuthor",{"name":7,"config":6003},{"headshot":6004,"ctfId":6005},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1749659879/Blog/Author%20Headshots/dnsmichi-headshot.jpg","dnsmichi","yml",{},"/en-us/blog/authors/michael-friedrich",{},"en-us/blog/authors/michael-friedrich","lJ-nfRIhdG49Arfrxdn1Vv4UppwD51BB13S3HwIswt4",[6013,6021,6028],{"title":6014,"description":6015,"heroImage":6016,"category":5294,"date":6017,"authors":6018,"slug":6020,"externalUrl":5298},"Loop Engineeringの実践方法：GitLab × Claude Codeでの実装例","GitLabとClaude Codeで実践するLoop Engineeringの実装例をご紹介。AIエージェントを自律稼働させるcron起動・Skills活用・ラベルベースのフローと、必須のガードレール設計を解説します。","https://res.cloudinary.com/about-gitlab-com/image/upload/v1785215335/oevhcbrbev1zyfubdfxz.jpg","2026-07-31",[6019],"Issei Hamada, Sony Biz Networks Corporation","loop-engineering-gitlab-claude-code",{"title":6022,"description":6023,"heroImage":6024,"category":5294,"date":6017,"authors":6025,"slug":6027,"externalUrl":5298},"エージェント型AI、MCP、AIコードアシスタントを統制する方法","AIエージェントは、各ステップで人によるレビューを介さずに、コードの記述、プッシュ、デプロイを行うことができます。アクセス、権限、監査証跡を統制する実践的なフレームワークを解説します。","https://res.cloudinary.com/about-gitlab-com/image/upload/v1785337625/ifzlc2hyzaxhzmjgyymh.png",[6026],"Julie Griffin","govern-agentic-ai-mcps-code-assistants",{"title":6029,"description":6030,"heroImage":6031,"category":5294,"date":6032,"authors":6033,"slug":6035,"externalUrl":5298},"Claude Opus 5、GitLabで最難関タスクに挑む","AnthropicのClaude Opus 5がGitLab Duo Agent Platformで利用可能になりました。速度を犠牲にすることなく、より深い推論力を提供します。","https://res.cloudinary.com/about-gitlab-com/image/upload/v1750099203/Blog/Hero%20Images/Blog/Hero%20Images/blog-image-template-1800x945%20%2820%29_2bJGC5ZP3WheoqzlLT05C5_1750099203484.png","2026-07-27",[6034],"Brittany Lutz","claude-opus-5-on-gitlab-duo-agent-platform",{"promotions":6037},[6038,6051,6063,6075],{"id":6039,"categories":6040,"header":6041,"text":6042,"button":6043,"image":6048},"ai-modernization",[5294],"AIの真価、組織全体で発揮できていますか？","所要時間は5分以内です",{"text":6044,"config":6045},"AI成熟度スコアを確認する",{"href":6046,"dataGaName":6047,"dataGaLocation":5531},"/ja-jp/assessments/ai-modernization-assessment/","modernization assessment",{"config":6049},{"src":6050},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1772138786/qix0m7kwnd8x2fh1zq49.png",{"id":6052,"categories":6053,"header":6055,"text":6042,"button":6056,"image":6060},"devops-modernization",[6054,5862],"product","単にツールを管理するだけでなく、イノベーションを提供していますか？",{"text":6057,"config":6058},"DevOps成熟度スコアを確認しましょう",{"href":6059,"dataGaName":6047,"dataGaLocation":5531},"/ja-jp/assessments/devops-modernization-assessment/",{"config":6061},{"src":6062},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1772138785/eg818fmakweyuznttgid.png",{"id":6064,"categories":6065,"header":6067,"text":6042,"button":6068,"image":6072},"security-modernization",[6066],"security","スピードのためにセキュリティを犠牲にしていませんか？",{"text":6069,"config":6070},"セキュリティ成熟度スコアを確認しましょう",{"href":6071,"dataGaName":6047,"dataGaLocation":5531},"/ja-jp/assessments/security-modernization-assessment/",{"config":6073},{"src":6074},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1772138786/p4pbqd9nnjejg5ds6mdk.png",{"id":6076,"paths":6077,"header":6080,"text":6081,"button":6082,"image":6087},"github-azure-migration",[6078,6079],"migration-from-azure-devops-to-gitlab","integrating-azure-devops-scm-and-gitlab","チームはGitHubのAzure移行に対応できていますか？","GitHubはすでにAzureを基盤として再構築を進めています。それがあなたのチームにとって何を意味するのか、ご確認ください。",{"text":6083,"config":6084},"GitLabとGitHubの比較を見る",{"href":6085,"dataGaName":6086,"dataGaLocation":5531},"/ja-jp/compare/gitlab-vs-github/github-azure-migration/","github azure migration",{"config":6088},{"src":6062},{"header":6090,"blurb":6091,"button":6092,"secondaryButton":6096},"今すぐ開発をスピードアップ","DevSecOpsに特化したインテリジェントオーケストレーションプラットフォームで実現できることをご確認ください。\n",{"text":5325,"config":6093},{"href":6094,"dataGaName":5328,"dataGaLocation":6095},"https://gitlab.com/-/trial_registrations/new?glm_content=default-saas-trial&glm_source=about.gitlab.com/ja-jp/","feature",{"text":5647,"config":6097},{"href":5656,"dataGaName":5333,"dataGaLocation":6095},1786803790855]