両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン |
rust:language_memo [2024/06/16 06:26] – [いちいち細々とうるさいコンパイラを黙らせる😝] ともやん | rust:language_memo [2024/06/17 07:09] (現在) – [もしもハマってしまったら...🔰] ともやん |
---|
==== Try - Catch ステートメント ==== | ==== Try - Catch ステートメント ==== |
[[so>questions/55755552/what-is-the-rust-equivalent-to-a-try-catch-statement|error handling - What Is the Rust Equivalent to a Try-Catch Statement? - Stack Overflow]]\\ | [[so>questions/55755552/what-is-the-rust-equivalent-to-a-try-catch-statement|error handling - What Is the Rust Equivalent to a Try-Catch Statement? - Stack Overflow]]\\ |
| |
| ===== もしもハマってしまったら...🤪🔰 ===== |
| |
| ==== cargo add tokio してるのに #[tokio::main] が使えない 😅 ==== |
| [[so>questions/63874178/cannot-find-tokiomain-macro|rust - Cannot find tokio::main macro? - Stack Overflow]]\\ |
| <WRAP color_term> |
| <WRAP color_result><html><pre> |
| <font color="#F66151"><b>error[E0433]</b></font><b>: failed to resolve: could not find `main` in `tokio`</b> |
| <font color="#2A7BDE"><b>--> </b></font>src/main.rs:69:10 |
| <font color="#2A7BDE"><b>|</b></font> |
| <font color="#2A7BDE"><b>69</b></font> <font color="#2A7BDE"><b>|</b></font> #[tokio::main] |
| <font color="#2A7BDE"><b>| </b></font> <font color="#F66151"><b>^^^^</b></font> <font color="#F66151"><b>could not find `main` in `tokio`</b></font> |
| </pre></html></WRAP> |
| </WRAP> |
| |
| [[https://docs.rs/tokio/latest/tokio/attr.main.html|main in tokio - Rust]]\\ |
| <html><code>#[main]</code></html> には Cargo.toml の <html><code>features = ["rt", "macros"]</code></html> が必要です🤔\\ |
| Available on crate features <wrap em>rt</wrap> and <wrap em>macros</wrap> only.\\ |
| <WRAP color_term> |
| <WRAP color_command><html><pre> |
| <font color="#0087FF"><b>$</b></font> <font color="#26A269">bat</font><font color="#FF9999"> </font><font color="#A347BA">-p</font><font color="#FF9999"> </font><font color="#A347BA">--pager=never</font><font color="#FF9999"> </font><font color="#FF9999"><u style="text-decoration-style:solid">Cargo.toml</u></font> |
| </pre></html></WRAP> |
| <WRAP color_result><html><pre> |
| <font color="#F92672">tokio</font><font color="#F8F8F2"> = { </font><font color="#F92672">version</font><font color="#F8F8F2"> = </font><font color="#E6DB74">"1.38.0"</font><font color="#F8F8F2">, </font><font color="#F92672">features</font><font color="#F8F8F2"> = [</font><font color="#E6DB74">"rt"</font><font color="#F8F8F2">, </font><font color="#E6DB74">"macros"</font><font color="#F8F8F2">] }</font> |
| </pre></html></WRAP> |
| </WRAP> |
| |
| <html><code>#[tokio::main]</code></html> には Cargo.toml の <html><code>features = ["rt-multi-thread", "macros"]</code></html> が必要です🤔\\ |
| Note: The multi-threaded runtime requires the <wrap em>rt-multi-thread</wrap> feature flag.\\ |
| <WRAP color_term> |
| <WRAP color_command><html><pre> |
| <font color="#0087FF"><b>$</b></font> <font color="#26A269">bat</font><font color="#FF9999"> </font><font color="#A347BA">-p</font><font color="#FF9999"> </font><font color="#A347BA">--pager=never</font><font color="#FF9999"> </font><font color="#FF9999"><u style="text-decoration-style:solid">Cargo.toml</u></font> |
| </pre></html></WRAP> |
| <WRAP color_result><html><pre> |
| <font color="#F92672">tokio</font><font color="#F8F8F2"> = { </font><font color="#F92672">version</font><font color="#F8F8F2"> = </font><font color="#E6DB74">"1.38.0"</font><font color="#F8F8F2">, </font><font color="#F92672">features</font><font color="#F8F8F2"> = [</font><font color="#E6DB74">"rt-multi-thread"</font><font color="#F8F8F2">, </font><font color="#E6DB74">"macros"</font><font color="#F8F8F2">] }</font> |
| </pre></html></WRAP> |
| </WRAP> |
| |
===== FFI - Foreign Function Interface ===== | ===== FFI - Foreign Function Interface ===== |