From 61fb909559bc61e2179f3ea7b62b60e2e7df3ac0 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Wed, 2 Jan 2019 21:05:37 -0800 Subject: Update src/liballoc/vec.rs Add @centril's comment Co-Authored-By: scottmcm --- src/liballoc/vec.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/liballoc') diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index b987b94500f..30bcc034221 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -790,6 +790,10 @@ impl Vec { /// // Per the FFI method's docs, "32768 bytes is always enough". /// let mut dict = Vec::with_capacity(32_768); /// let mut dict_length = 0; + /// // SAFETY: When `deflateGetDictionary` returns `Z_OK`, it holds that: + /// // 1. `dict_length` elements were initialized. + /// // 2. `dict_length` <= the capacity (32_768) + /// // which makes `set_len` safe to call. /// unsafe { /// // Make the FFI call... /// let r = deflateGetDictionary(self.strm, dict.as_mut_ptr(), &mut dict_length); -- cgit 1.4.1-3-g733a5