Skip to content

Commit d0782c8

Browse files
committed
Add shallow cloning to unresolved questions.
1 parent d53f3a1 commit d0782c8

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

text/0000-pattern-3.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,8 +1455,22 @@ Unlike this RFC, the `Extract` class is much simpler.
14551455
though unit testing does suggest this works.
14561456

14571457
As mentioned in the RFC, there are faster algorithms for searching a `T: !Ord` slice.
1458-
It is not undecided if we should complicate the standard library to support this though.
1458+
It is not decided if we should complicate the standard library to support this though.
14591459

1460+
* We could represent `SharedHaystack` using a more general concept of "cheaply cloneable":
1461+
1462+
```rust
1463+
pub trait ShallowClone: Clone {}
1464+
impl<'a, T: ?Sized + 'a> ShallowClone for &'a T {}
1465+
impl<T: ?Sized> ShallowClone for Rc<T> {}
1466+
impl<T: ?Sized> ShallowClone for Arc<T> {}
1467+
```
1468+
1469+
and all `H: SharedHaystack` bound can be replaced by `H: Haystack + ShallowClone`.
1470+
But this generalization brings more questions e.g. should `[u32; N]: ShallowClone`.
1471+
This should be better left to a new RFC, and since `SharedHaystack` is mainly used for
1472+
the core type `&A` only, we could keep `SharedHaystack` unstable longer
1473+
(a separate track from the main Pattern API) until this question is resolved.
14601474

14611475
[RFC 528]: https://github.com/rust-lang/rfcs/pull/528
14621476
[RFC 1309]: https://github.com/rust-lang/rfcs/pull/1309

0 commit comments

Comments
 (0)