To remove the need to convert to a slice expliclty a[Slice(1)] one can make Slice conform to ExpressibleByIntegerLiteral.
This should not be done before the old index API is removed, since old slices with strides:
let a = A[0..., 2]
would be interpreted as
let a = A[0..., Slice(2)]
leading to unexpected behaviour.
/**
Auto convert integer literals to an index slice.
let s = a[..., 1]
*/
extension Slice: ExpressibleByIntegerLiteral {
public typealias IntegerLiteralType = Int
public init(integerLiteral i: Int) {
self.init(i)
}
}
To remove the need to convert to a slice expliclty
a[Slice(1)]
one can makeSlice
conform toExpressibleByIntegerLiteral
. This should not be done before the old index API is removed, since old slices with strides:would be interpreted as
leading to unexpected behaviour.