Content deleted Content added
the example I removed appears to have been intended as COBOL: Special:Diff/619852196 |
Rust indexing |
||
Line 1,639:
|<code>''n''↑''string''.</code>
|[[APL (programming language)|APL]]
|-
| <code>''string''[0..n]</code><br><code>''string''[..n]</code><br><code>''string''.get(0..n)</code><br><code>''string''.get(..n)</code>
| [[Rust (programming language)|Rust]]<ref name="Rust indexing">In Rust, strings are indexed in terms of byte offsets and there is a runtime panic if the index is out of bounds or if it would result in invalid [[UTF-8]]. A <code>&str</code> (string reference) can be [https://doc.rust-lang.org/stable/std/primitive.str.html#impl-Index%3CI%3E indexed] by various types of ranges, including [https://doc.rust-lang.org/stable/std/slice/trait.SliceIndex.html#impl-SliceIndex%3Cstr%3E <code>Range</code>] (<code>0..n</code>), [https://doc.rust-lang.org/stable/std/slice/trait.SliceIndex.html#impl-SliceIndex%3Cstr%3E-1 <code>RangeFrom</code>] (<code>n..</code>), and [https://doc.rust-lang.org/stable/std/slice/trait.SliceIndex.html#impl-SliceIndex%3Cstr%3E-4 <code>RangeTo</code>] (<code>..n</code>) because they all implement the [https://doc.rust-lang.org/stable/std/slice/trait.SliceIndex.html <code>SliceIndex</code>] trait with <code>str</code> being the type being indexed.
The [https://doc.rust-lang.org/stable/std/primitive.str.html#method.get <code>str::get</code>] method is the non-panicking way to index. It returns [[option type|<code>None</code>]] in the cases in which indexing would panic.</ref>
|}
Line 2,548 ⟶ 2,553:
|<code>''¯n''↑''string''.</code>
|[[APL (programming language)|APL]]
|-
| <code>''string''[n..]</code><br><code>''string''.get(n..)</code>
| [[Rust (programming language)|Rust]]<ref name="Rust indexing" />
|}
Line 2,875 ⟶ 2,883:
|string range ''string startpos endpos''
|[[Tcl]]
|-
| <code>''string''[''startpos''..''endpos'']</code><br><code>''string''.get(''startpos''..''endpos'')</code>
| [[Rust (programming language)|Rust]]<ref name="Rust indexing" />
|}
|