style: Document nsTArray sugar module.

This commit is contained in:
Emilio Cobos Álvarez 2017-01-02 03:02:52 +01:00
parent 1d19e81c8b
commit 1fc48dc730
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Rust helpers for Gecko's nsTArray.
use gecko_bindings::bindings; use gecko_bindings::bindings;
use gecko_bindings::structs::{nsTArray, nsTArrayHeader}; use gecko_bindings::structs::{nsTArray, nsTArrayHeader};
use std::mem; use std::mem;
@ -78,10 +80,12 @@ impl<T> nsTArray<T> {
unsafe { self.clear() } unsafe { self.clear() }
} }
// unsafe because the array may contain uninits /// Resize and set the length of the array to `len`.
// This will not call constructors, either manually ///
// add bindings or run the typed ensurecapacity call /// unsafe because the array may contain uninitialized members.
// on the gecko side ///
/// This will not call constructors, if you need that, either manually add
/// bindings or run the typed `EnsureCapacity` call on the gecko side.
pub unsafe fn set_len(&mut self, len: u32) { pub unsafe fn set_len(&mut self, len: u32) {
// this can leak // this can leak
debug_assert!(len >= self.len() as u32); debug_assert!(len >= self.len() as u32);