Skip to content

Commit 8fa10b2

Browse files
committed
[doc] clarify docs for load, loadUnaligned and storeBytes
- outdated and incorrect information removed
1 parent f62fd9d commit 8fa10b2

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

stdlib/public/core/UnsafeRawBufferPointer.swift.gyb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,10 @@ extension Unsafe${Mutable}RawBufferPointer {
350350
/// Returns a new instance of the given type, read from the buffer pointer's
351351
/// raw memory at the specified byte offset.
352352
///
353+
/// The memory at `offset` bytes from this buffer pointer's `baseAddress`
354+
/// must be properly aligned for accessing `T` and initialized to `T` or
355+
/// another type that is layout compatible with `T`.
356+
///
353357
/// You can use this method to create new values from the buffer pointer's
354358
/// underlying bytes. The following example creates two new `Int32`
355359
/// instances from the memory referenced by the buffer pointer `someBytes`.
@@ -394,20 +398,18 @@ extension Unsafe${Mutable}RawBufferPointer {
394398
/// underlying bytes. The following example creates two new `Int32`
395399
/// instances from the memory referenced by the buffer pointer `someBytes`.
396400
/// The bytes for `a` are copied from the first four bytes of `someBytes`,
397-
/// and the bytes for `b` are copied from the next four bytes.
401+
/// and the bytes for `b` are copied from the fourth through seventh bytes.
398402
///
399-
/// let a = someBytes.load(as: Int32.self)
400-
/// let b = someBytes.load(fromByteOffset: 4, as: Int32.self)
403+
/// let a = someBytes.loadUnaligned(as: Int32.self)
404+
/// let b = someBytes.loadUnaligned(fromByteOffset: 3, as: Int32.self)
401405
///
402406
/// The memory to read for the new instance must not extend beyond the buffer
403407
/// pointer's memory region---that is, `offset + MemoryLayout<T>.size` must
404408
/// be less than or equal to the buffer pointer's `count`.
405409
///
406410
/// - Parameters:
407411
/// - offset: The offset, in bytes, into the buffer pointer's memory at
408-
/// which to begin reading data for the new instance. The buffer pointer
409-
/// plus `offset` must be properly aligned for accessing an instance of
410-
/// type `T`. The default is zero.
412+
/// which to begin reading data for the new instance. The default is zero.
411413
/// - type: The type to use for the newly constructed instance. The memory
412414
/// must be initialized to a value of a type that is layout compatible
413415
/// with `type`.
@@ -455,9 +457,7 @@ extension Unsafe${Mutable}RawBufferPointer {
455457
/// - Parameters:
456458
/// - value: The value to store as raw bytes.
457459
/// - offset: The offset in bytes into the buffer pointer's memory to begin
458-
/// reading data for the new instance. The buffer pointer plus `offset`
459-
/// must be properly aligned for accessing an instance of type `T`. The
460-
/// default is zero.
460+
/// reading data for the new instance. The default is zero.
461461
/// - type: The type to use for the newly constructed instance. The memory
462462
/// must be initialized to a value of a type that is layout compatible
463463
/// with `type`.

0 commit comments

Comments
 (0)