<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">As I understand it, that’s not an error in the ‘try’ sense of the word. If that failure happens, it’s a catastrophic issue which should bring down the application.<div class=""><br class=""></div><div class="">So the initialiser shouldn’t be failable; you’re right. File a bug at <a href="http://bugs.swift.org" class="">bugs.swift.org</a>.</div><div class=""><br class=""></div><div class="">Karl</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 18 Jun 2016, at 06:06, Saagar Jha via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><p class=""><a href="http://article.gmane.org/gmane.comp.lang.swift.user/1702" class="">This</a> might be relavant. Basically, <code class="">Data</code>’s <code class="">init</code> will fail if memory can’t be allocated for it.</p>
<br class=""><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Fri, Jun 17, 2016 at 11:38 AM Adrian Zubarev via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><p class="">Hello there, I’m trying to optimize my code and reduce copying from different buffers into a new one.</p><p class="">I thought I just create a Data value with enough capacity and write directly into it. My problem is that <code class="">Data.init?(capacity:)</code> can fail, but why and when?</p><p class="">Can someone explain this behavior to me?</p><p class="">I’m sending data via TCP sockets and when <code class="">recn</code> function write directly into a <code class="">Data</code> struct. </p><div class=""><br class="webkit-block-placeholder"></div></div><div class=""><div style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class=""><br class=""></div><br class=""><div class=""><div style="font-family:helvetica,arial;font-size:13px" class="">--&nbsp;<br class="">Adrian Zubarev<br class="">Sent with Airmail</div></div></div><div class=""><div class=""><br class="webkit-block-placeholder"></div></div></div>_______________________________________________<br class="">
swift-users mailing list<br class="">
<a href="mailto:swift-users@swift.org" target="_blank" class="">swift-users@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-users</a><br class="">
</blockquote></div></div><div dir="ltr" class="">-- <br class=""></div><div data-smartmail="gmail_signature" class=""><div dir="ltr" class="">-Saagar Jha</div></div>
_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""></div></body></html>