「Rust筆記」修訂間的差異

增加 168 位元組 、 2024年3月16日 (星期六)
行 55: 行 55:
# 得到 UTF-8 字串長度的方法:[https://docs.rs/unicode-segmentation/1.6.0/unicode_segmentation/index.html UnicodeSegmentation::graphemes](參見:[https://stackoverflow.com/questions/46290655/get-the-string-length-in-characters-in-rust Stack Overflow])
# 得到 UTF-8 字串長度的方法:[https://docs.rs/unicode-segmentation/1.6.0/unicode_segmentation/index.html UnicodeSegmentation::graphemes](參見:[https://stackoverflow.com/questions/46290655/get-the-string-length-in-characters-in-rust Stack Overflow])
# [https://stackoverflow.com/questions/45519176/how-do-i-use-or-import-a-local-rust-file 匯入外部函式庫]
# [https://stackoverflow.com/questions/45519176/how-do-i-use-or-import-a-local-rust-file 匯入外部函式庫]
===印出當前目錄(current directory)===
===印出當前目錄(current directory)===
<pre>
<pre>
行 63: 行 64:
執行結果:
執行結果:
<code>Ok("[project_dir]")</code>
<code>Ok("[project_dir]")</code>
===sysargv 傳入程式的引數===
求出引數個數長度,沒輸入自定引數則為0:
<pre>
use std::env;
...
    println!("{}", env::args().len());
</pre>


==變數==
==變數==