@@ -350,6 +350,10 @@ extension Unsafe${Mutable}RawBufferPointer {
350
350
/// Returns a new instance of the given type, read from the buffer pointer's
351
351
/// raw memory at the specified byte offset.
352
352
///
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
+ ///
353
357
/// You can use this method to create new values from the buffer pointer's
354
358
/// underlying bytes. The following example creates two new `Int32`
355
359
/// instances from the memory referenced by the buffer pointer `someBytes`.
@@ -394,20 +398,18 @@ extension Unsafe${Mutable}RawBufferPointer {
394
398
/// underlying bytes. The following example creates two new `Int32`
395
399
/// instances from the memory referenced by the buffer pointer `someBytes`.
396
400
/// 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.
398
402
///
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)
401
405
///
402
406
/// The memory to read for the new instance must not extend beyond the buffer
403
407
/// pointer's memory region---that is, `offset + MemoryLayout<T>.size` must
404
408
/// be less than or equal to the buffer pointer's `count`.
405
409
///
406
410
/// - Parameters:
407
411
/// - 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.
411
413
/// - type: The type to use for the newly constructed instance. The memory
412
414
/// must be initialized to a value of a type that is layout compatible
413
415
/// with `type`.
@@ -455,9 +457,7 @@ extension Unsafe${Mutable}RawBufferPointer {
455
457
/// - Parameters:
456
458
/// - value: The value to store as raw bytes.
457
459
/// - 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.
461
461
/// - type: The type to use for the newly constructed instance. The memory
462
462
/// must be initialized to a value of a type that is layout compatible
463
463
/// with `type`.
0 commit comments