Skip to content

Commit 11775ab

Browse files
committed
Clarify how needs_drop is conservative
1 parent 91eb6fe commit 11775ab

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/libcore/mem.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,11 @@ pub fn align_of_val<T: ?Sized>(val: &T) -> usize {
429429

430430
/// Returns whether dropping values of type `T` matters.
431431
///
432-
/// This is purely an optimization hint, and may be implemented conservatively.
433-
/// For instance, always returning `true` would be a valid implementation of
434-
/// this function.
432+
/// This is purely an optimization hint, and may be implemented conservatively:
433+
/// it may return `true` for types that don't actually need to be dropped.
434+
/// As such always returning `true` would be a valid implementation of
435+
/// this function. However if this function actually returns `false`, then you
436+
/// can be certain dropping `T` has no side effect.
435437
///
436438
/// Low level implementations of things like collections, which need to manually
437439
/// drop their data, should use this function to avoid unnecessarily

0 commit comments

Comments
 (0)