diff options
| author | nsfisis <nsfisis@gmail.com> | 2023-03-12 15:12:10 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2023-03-12 15:12:10 +0900 |
| commit | de13d68cddef5bb321469bcffb868f27ddd5390e (patch) | |
| tree | 3183bb2bc8b2ad7d34b6953e6a248747239f0afa /public/posts/2021-10-02/rust-where-are-primitive-types-from | |
| parent | 5b49e6bca39d7cd3b98db8b826dc597d9f758a26 (diff) | |
| download | blog.nsfisis.dev-de13d68cddef5bb321469bcffb868f27ddd5390e.tar.gz blog.nsfisis.dev-de13d68cddef5bb321469bcffb868f27ddd5390e.tar.zst blog.nsfisis.dev-de13d68cddef5bb321469bcffb868f27ddd5390e.zip | |
style: add .highlight class to pre tag
Diffstat (limited to 'public/posts/2021-10-02/rust-where-are-primitive-types-from')
| -rw-r--r-- | public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html b/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html index 8879a79..8bcb923 100644 --- a/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html +++ b/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html @@ -55,7 +55,7 @@ Rust において、プリミティブ型の名前は予約語でない。したがって、次のコードは合法である。 </p> - <pre language="rust" linenumbering="unnumbered"> + <pre class="highlight" language="rust" linenumbering="unnumbered"> <code>#![allow(non_camel_case_types)] #![allow(dead_code)] @@ -111,7 +111,7 @@ struct str;</code> <code>rustc</code>はセルフホストされている (=<code>rustc</code>自身が Rust で書かれている) ので、<code>bool</code>や<code>char</code>などで適当に検索をかけてもノイズが多すぎて話にならない。 しかし、お誂え向きなことに<code>i128</code>/<code>u128</code>というコンパイラ自身が使うことがなさそうな型が存在するのでこれを使って<code>git grep</code>してみる。 </p> - <pre class="monospaced"> + <pre class="monospaced highlight"> <code>$ git grep "\bi128\b" | wc # i128 165 1069 15790 @@ -126,7 +126,7 @@ $ git grep "\bbool\b" | wc # cf. bool の結果 165 程度であれば探すことができそうだ。今回は、クレート名を見ておおよその当たりをつけた。 </p> - <pre class="monospaced"> + <pre class="monospaced highlight"> <code>$ git grep "\bi128\b" ... rustc_resolve/src/lib.rs: table.insert(sym::i128, Int(IntTy::I128)); @@ -137,7 +137,7 @@ rustc_resolve/src/lib.rs: table.insert(sym::i128, Int(IntTy::I128)); <code>rustc_resolve</code>というのはいかにも名前解決を担いそうなクレート名である。該当箇所を見てみる。 </p> - <pre language="rust" linenumbering="unnumbered"> + <pre class="highlight" language="rust" linenumbering="unnumbered"> <code>/// Interns the names of the primitive types. /// /// All other types are defined somewhere and possibly imported, but the primitive ones need @@ -186,7 +186,7 @@ Self { primitive_types: table } とある。次はこの struct の使用箇所を追う。追うと言っても使われている箇所は次の一箇所しかない。なお説明に不要な箇所は大きく削っている。 </p> - <pre language="rust" linenumbering="unnumbered"> + <pre class="highlight" language="rust" linenumbering="unnumbered"> <code> /// This resolves the identifier `ident` in the namespace `ns` in the current lexical scope. /// (略) fn resolve_ident_in_lexical_scope( @@ -226,7 +226,7 @@ None 動作がわかったところで、例として次のコードを考える。 </p> - <pre language="rust" linenumbering="unnumbered"> + <pre class="highlight" language="rust" linenumbering="unnumbered"> <code>#![allow(non_camel_case_types)] struct bool; |
