Commit 274e299
committed
Stablize slice::strip_prefix and strip_suffix, with SlicePattern
We hope later to extend `core::str::Pattern` to slices too, perhaps as
part of stabilising that. We want to minimise the amount of type
inference breakage when we do that, so we don't want to stabilise
strip_prefix and strip_suffix taking a simple `&[T]`.
@KodrAus suggested the approach of introducing a new perma-unstable
trait, which reduces this future inference break risk.
I found it necessary to make two impls of this trait, as the unsize
coercion don't apply when hunting for trait implementations.
Since SlicePattern's only method returns a reference, and the whole
trait is just a wrapper for slices, I made the trait type be the
non-reference type [T] or [T;N] rather than the reference. Otherwise
the trait would have a lifetime parameter.
I marked both the no-op conversion functions `#[inline]`. I'm not
sure if that is necessary but it seemed at the very least harmless.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>1 parent 0b644e4 commit 274e299
2 files changed
+41
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1778 | 1778 | | |
1779 | 1779 | | |
1780 | 1780 | | |
1781 | | - | |
1782 | 1781 | | |
1783 | 1782 | | |
1784 | 1783 | | |
1785 | 1784 | | |
1786 | 1785 | | |
1787 | 1786 | | |
1788 | 1787 | | |
1789 | | - | |
1790 | | - | |
| 1788 | + | |
| 1789 | + | |
1791 | 1790 | | |
1792 | 1791 | | |
1793 | 1792 | | |
1794 | | - | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
1795 | 1796 | | |
1796 | 1797 | | |
1797 | 1798 | | |
| |||
1811 | 1812 | | |
1812 | 1813 | | |
1813 | 1814 | | |
1814 | | - | |
1815 | 1815 | | |
1816 | 1816 | | |
1817 | 1817 | | |
1818 | 1818 | | |
1819 | 1819 | | |
1820 | 1820 | | |
1821 | 1821 | | |
1822 | | - | |
1823 | | - | |
| 1822 | + | |
| 1823 | + | |
1824 | 1824 | | |
1825 | 1825 | | |
1826 | 1826 | | |
| 1827 | + | |
| 1828 | + | |
1827 | 1829 | | |
1828 | 1830 | | |
1829 | 1831 | | |
| |||
3216 | 3218 | | |
3217 | 3219 | | |
3218 | 3220 | | |
| 3221 | + | |
| 3222 | + | |
| 3223 | + | |
| 3224 | + | |
| 3225 | + | |
| 3226 | + | |
| 3227 | + | |
| 3228 | + | |
| 3229 | + | |
| 3230 | + | |
| 3231 | + | |
| 3232 | + | |
| 3233 | + | |
| 3234 | + | |
| 3235 | + | |
| 3236 | + | |
| 3237 | + | |
| 3238 | + | |
| 3239 | + | |
| 3240 | + | |
| 3241 | + | |
| 3242 | + | |
| 3243 | + | |
| 3244 | + | |
| 3245 | + | |
| 3246 | + | |
| 3247 | + | |
| 3248 | + | |
| 3249 | + | |
| 3250 | + | |
| 3251 | + | |
| 3252 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
307 | 307 | | |
308 | 308 | | |
309 | 309 | | |
310 | | - | |
311 | 310 | | |
312 | 311 | | |
313 | 312 | | |
| |||
0 commit comments