mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
style: Document nsTArray sugar module.
This commit is contained in:
parent
1d19e81c8b
commit
1fc48dc730
1 changed files with 8 additions and 4 deletions
|
@ -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);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue