<div dir="ltr">Would this require a review/proposal, since it involves an API change?</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 7, 2015 at 2:08 PM, Dmitri Gribenko via swift-dev <span dir="ltr">&lt;<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
If someone looks for a starter project in the standard library with<br>
intermediate complexity (prior experience with Swift generics<br>
required), here&#39;s one.<br>
<br>
This is in the area of existential sequence and collection wrappers.<br>
<br>
Upgrading AnyForwardCollection to AnyRandomAccessCollection works:<br>
<br>
(swift) AnyRandomAccessCollection(AnyForwardCollection([1,2,3]))<br>
// r2 : AnyRandomAccessCollection&lt;Int&gt;? =<br>
Optional(Swift.AnyRandomAccessCollection&lt;Swift.Int&gt;(_box:<br>
Swift._CollectionBox&lt;Swift.Array&lt;Swift.Int&gt;&gt;))<br>
<br>
Seems like we don&#39;t provide APIs to upgrade AnySequence to Any*Collection:<br>
<br>
(swift) AnyRandomAccessCollection(AnySequence([1,2,3]))<br>
&lt;REPL Input&gt;:1:1: error: cannot invoke initializer for type<br>
&#39;AnyRandomAccessCollection&lt;_&gt;&#39; with an argument list of type<br>
&#39;(AnySequence&lt;Int&gt;)&#39;<br>
<br>
Of course, this should work without copying the underlying collection.<br>
<br>
<a href="https://bugs.swift.org/browse/SR-119" rel="noreferrer" target="_blank">https://bugs.swift.org/browse/SR-119</a><br>
<span class="HOEnZb"><font color="#888888"><br>
Dmitri<br>
<br>
--<br>
main(i,j){for(i=2;;i++){for(j=2;j&lt;i;j++){if(!(i%j)){j=0;break;}}if<br>
(j){printf(&quot;%d\n&quot;,i);}}} /*Dmitri Gribenko &lt;<a href="mailto:gribozavr@gmail.com">gribozavr@gmail.com</a>&gt;*/<br>
_______________________________________________<br>
swift-dev mailing list<br>
<a href="mailto:swift-dev@swift.org">swift-dev@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-dev" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-dev</a><br>
</font></span></blockquote></div><br></div>