You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure about the unbounded versions though. Following my above suggestions it would be:
foo[n,] for foo.slice_from(n) or foo[n..]
foo[,m] for foo.slice_to(m) or foo[..m]
But right there the #198 notations appeals to me more. Another alternative, that also helps prevent typos would be to require an underscore for open ended intervals.
foo[n,_] for foo.slice_from(n) or foo[n..]
foo[_,m] for foo.slice_to(m) or foo[..m]
Intervals are not ranges. So technically this should be a way to declare intervals which then could be passed to the slice function. But i do not think the following looks readable (which is the whole point of this feature request).
foo[[n,m[] for foo.slice(n, m) or foo[n..m]
The text was updated successfully, but these errors were encountered:
Anything which uses unbalanced brackets of any kind is a non-starter since it will break the tokeniser and confuse every editor in existence. I guess the other suggestions could be considered, but most people seem pretty happy with the existing syntax (with some minor disagreement with [] vs [..]).
https://github.com/rust-lang/rfcs/blob/master/text/0198-slice-notation.md introduced the [start..end] syntax for slices. There was some serious discussion about the readability of the notation (#198). I suggest using interval notation (https://en.wikipedia.org/wiki/Interval_%28mathematics%29).
Using
[)
,(]
or()
like in the docs (http://doc.rust-lang.org/std/slice/trait.ImmutableSlice.html#tymethod.slice) is not a good idea, since it'll be confused with function syntax. But the alternative (US) notation[[
,]]
or][
is also part of the ISO 80000-2 standard (behind paywall, or google "international iso standard 80000-2 interval notation").foo][
forfoo.as_slice()
foo[n,m[
forfoo.slice(n, m)
orfoo[n..m]
foo[n,m]
forfoo.slice(n, m+1)
foo]n,m]
forfoo.slice(n+1, m+1)
foo]n,m[
forfoo.slice(n+1, m)
mut
variants of all the aboveI'm not sure about the unbounded versions though. Following my above suggestions it would be:
foo[n,]
forfoo.slice_from(n)
orfoo[n..]
foo[,m]
forfoo.slice_to(m)
orfoo[..m]
But right there the #198 notations appeals to me more. Another alternative, that also helps prevent typos would be to require an underscore for open ended intervals.
foo[n,_]
forfoo.slice_from(n)
orfoo[n..]
foo[_,m]
forfoo.slice_to(m)
orfoo[..m]
Intervals are not ranges. So technically this should be a way to declare intervals which then could be passed to the slice function. But i do not think the following looks readable (which is the whole point of this feature request).
foo[[n,m[]
forfoo.slice(n, m)
orfoo[n..m]
The text was updated successfully, but these errors were encountered: