Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safe Access to Contiguous Storage #2307

Open
wants to merge 49 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
8093cad
[draft proposal] Safe Access to Contiguous Storage
glessard Feb 6, 2024
548b250
edit placeholder proposal url
glessard Feb 6, 2024
7cfd46d
link to pitch thread
glessard Feb 6, 2024
9993694
declare typealiases correctly
glessard Feb 9, 2024
fece228
add “first” and “last” properties
glessard Feb 9, 2024
a3784fe
fix inits from raw pointers
glessard Feb 9, 2024
ceb261d
Update proposals/nnnn-safe-shared-contiguous-storage.md
glessard Feb 14, 2024
2480ca2
add `view(as: T)`
glessard Feb 14, 2024
441a5c8
incorporate feedback from pitch discussion
glessard Feb 15, 2024
b360a50
enclose index and iterator types in the main type
glessard Feb 17, 2024
9aa96ea
update protocol declaration
glessard Feb 23, 2024
1adba6d
link to additional related pitches
glessard Feb 24, 2024
300591d
fix a stored property type
glessard Apr 16, 2024
ed5fea2
rename type, adopt new syntax
glessard Apr 17, 2024
7b2bb1f
various updates
glessard Apr 19, 2024
f876043
add more RawSpan API, doc-comment fixes
glessard Apr 21, 2024
844e661
Added more prose, added TODOs for further clarification
milseman Apr 22, 2024
15de4ab
Update proposals/nnnn-safe-shared-contiguous-storage.md
glessard Apr 22, 2024
be180f1
remove some trailing whitespace from code blocks
glessard Apr 23, 2024
26a7637
Update
milseman May 6, 2024
50a38df
Update
glessard May 24, 2024
6add19b
lots of updates
glessard Jun 20, 2024
5d19ead
Apply suggestions from code review
glessard Jun 20, 2024
d46c815
Move byte parsing helpers into a future direction
milseman Jun 20, 2024
d87f041
Fill out the index appendix
milseman Jun 20, 2024
a5239b4
tweaks and corrections
glessard Jun 21, 2024
99f305a
add missing keywords
glessard Jun 21, 2024
b3db4b4
Apply editing suggestions from review
glessard Jun 21, 2024
d728217
annotation adjustments, various edits
glessard Jun 22, 2024
a0d3b87
some more edits
glessard Jun 22, 2024
90890a5
move `ContiguousStorage` to future directions
glessard Jun 22, 2024
2d463ab
edits about unsafe initializer usage
glessard Jun 25, 2024
c8b2d5c
remove “generally” from index-sharing note
glessard Jun 25, 2024
859a071
improve index validation functions
glessard Jun 25, 2024
e924bab
omit some duplicated documentation
glessard Jun 25, 2024
1844c97
add html anchors to important sections
glessard Jun 25, 2024
385cccb
add link to second pitch thread
glessard Jun 26, 2024
5266e65
more cleanup surrounding `ContiguousStorage`
glessard Jun 28, 2024
913f6e1
whitespace fixes
glessard Jun 28, 2024
ba482d9
Change some uses of the word “view” to “span” instead
glessard Jun 30, 2024
9370b13
fix misspelling
glessard Jun 30, 2024
572a236
add missing doc-comment paragraph
glessard Jun 30, 2024
c9c312c
change `uncheckedBounds` to `unchecked`
glessard Jun 30, 2024
42170bf
fix doc-comments
glessard Jun 30, 2024
1319b1d
rework `load` and company
glessard Jun 30, 2024
66bcb19
add the `SurjectiveBitPattern` future direction
glessard Jul 1, 2024
f84aefc
more about `SurjectiveBitPattern`, plus an alternative
glessard Jul 1, 2024
4b13bcd
move reference to SE-0256 to the ContiguousStorage item
glessard Jul 1, 2024
7a88571
reword coroutine accessors
glessard Jul 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
omit some duplicated documentation
  • Loading branch information
glessard committed Jun 25, 2024
commit e924bab3d24424271982613e5dec24c699bc9dd0
96 changes: 4 additions & 92 deletions proposals/nnnn-safe-shared-contiguous-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -709,119 +709,31 @@ extension RawSpan {

##### Accessing subranges of elements:

Similarly to `Span`, `RawSpan` does not support slicing in the style of `Collection`. It supports the same set of `extracting()` functions as `Span`:
Similarly to `Span`, `RawSpan` does not support slicing in the style of `Collection`. It supports the same set of `extracting()` functions as `Span`. The documentation is omitted here, as it is substantially the same as for `Span`:

```swift
extension RawSpan {
/// Constructs a new span over the bytes within the supplied range of
/// positions within this span.
///
/// The returned span's first byte is always at offset 0; unlike buffer
/// slices, extracted spans do not share their indices with the
/// span from which they are extracted.
///
/// - Parameter bounds: A valid range of positions. Every position in
/// this range must be within the bounds of this `RawSpan`.
///
/// - Returns: A span over the bytes within `bounds`

public func extracting(_ bounds: Range<Int>) -> Self

/// Constructs a new span over the bytes within the supplied range of
/// positions within this span.
///
/// The returned span's first byte is always at offset 0; unlike buffer
/// slices, extracted spans do not share their indices with the
/// span from which they are extracted.
///
/// This function does not validate `bounds`; this is an unsafe operation.
///
/// - Parameter bounds: A valid range of positions. Every position in
/// this range must be within the bounds of this `RawSpan`.
///
/// - Returns: A span over the bytes within `bounds`
public func extracting(uncheckedBounds bounds: Range<Int>) -> Self

/// Constructs a new span over the bytes within the supplied range of
/// positions within this span.
///
/// The returned span's first byte is always at offset 0; unlike buffer
/// slices, extracted spans do not share their indices with the
/// span from which they are extracted.
///
/// - Parameter bounds: A valid range of positions. Every position in
/// this range must be within the bounds of this `RawSpan`.
///
/// - Returns: A span over the bytes within `bounds`

public func extracting(_ bounds: some RangeExpression<Int>) -> Self

/// Constructs a new span over the bytes within the supplied range of
/// positions within this span.
///
/// The returned span's first byte is always at offset 0; unlike buffer
/// slices, extracted spans do not share their indices with the
/// span from which they are extracted.
///
/// This function does not validate `bounds`; this is an unsafe operation.
///
/// - Parameter bounds: A valid range of positions. Every position in
/// this range must be within the bounds of this `RawSpan`.
///
/// - Returns: A span over the bytes within `bounds`

public func extracting(
uncheckedBounds bounds: some RangeExpression<Int>
) -> Self

/// Constructs a new span over all the bytes of this span.
///
/// The returned span's first byte is always at offset 0; unlike buffer
/// slices, extracted spans do not share their indices with the
/// span from which they are extracted.
///
/// - Returns: A span over all the bytes of this span.
public func extracting(_: UnboundedRange) -> Self

// extracting prefixes and suffixes

/// Returns a span containing the initial bytes of this span,
/// up to the specified maximum byte count.
///
/// If the maximum length exceeds the length of this span,
/// the result contains all the bytes.
///
/// - Parameter maxLength: The maximum number of bytes to return.
/// `maxLength` must be greater than or equal to zero.
/// - Returns: A span with at most `maxLength` bytes.
public func extracting(first maxLength: Int) -> Self

/// Returns a span over all but the given number of trailing bytes.
///
/// If the number of elements to drop exceeds the number of elements in
/// the span, the result is an empty span.
///
/// - Parameter k: The number of bytes to drop off the end of
/// the span. `k` must be greater than or equal to zero.
/// - Returns: A span leaving off the specified number of bytes at the end.
public func extracting(droppingLast k: Int) -> Self

/// Returns a span containing the trailing bytes of the span,
/// up to the given maximum length.
///
/// If the maximum length exceeds the length of this span,
/// the result contains all the bytes.
///
/// - Parameter maxLength: The maximum number of bytes to return.
/// `maxLength` must be greater than or equal to zero.
/// - Returns: A span with at most `maxLength` bytes.
public func extracting(last maxLength: Int) -> Self

/// Returns a span over all but the given number of initial bytes.
///
/// If the number of elements to drop exceeds the number of bytes in
/// the span, the result is an empty span.
///
/// - Parameter k: The number of bytes to drop from the beginning of
/// the span. `k` must be greater than or equal to zero.
/// - Returns: A span starting after the specified number of bytes.
public func extracting(droppingFirst k: Int = 1) -> Self
glessard marked this conversation as resolved.
Show resolved Hide resolved
}
```
Expand Down