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 39 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
39 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
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
Apply editing suggestions from review
Co-authored-by: Karoy Lorentey <[email protected]>
  • Loading branch information
glessard and lorentey committed Jun 21, 2024
commit b3db4b4ca38a365ca40c3316a6a96f6a44098ffc
17 changes: 8 additions & 9 deletions proposals/nnnn-safe-shared-contiguous-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,9 @@ extension Span {
/// for the `withUnsafeBufferPointer(_:)` method. The closure's
/// parameter is valid only for the duration of its execution.
/// - Returns: The return value of the `body` closure parameter.
func withUnsafeBufferPointer<Result>(
_ body: (_ buffer: UnsafeBufferPointer<Element>) -> Result
) -> Result
func withUnsafeBufferPointer<E: Error, Result: ~Copyable>(
_ body: (_ buffer: UnsafeBufferPointer<Element>) throws(E) -> Result
) throws(E) -> Result
}

extension Span where Element: BitwiseCopyable {
Expand All @@ -538,9 +538,9 @@ extension Span where Element: BitwiseCopyable {
/// The closure's parameter is valid only for the duration of
/// its execution.
/// - Returns: The return value of the `body` closure parameter.
func withUnsafeBytes<Result>(
_ body: (_ buffer: UnsafeRawBufferPointer) -> Result
) -> Result
func withUnsafeBytes<E: Error, Result: ~Copyable>(
_ body: (_ buffer: UnsafeRawBufferPointer) throws(E) -> Result
) throws(E) -> Result
}
```

Expand Down Expand Up @@ -597,7 +597,6 @@ extension RawSpan {
/// - Parameters:
/// - span: An existing `Span<T>`, which will define both this
/// `RawSpan`'s lifetime and the memory it represents.
@inlinable @inline(__always)
public init<T: BitwiseCopyable>(
_ span: borrowing Span<T>
) -> dependsOn(span) Self
Expand Down Expand Up @@ -747,7 +746,7 @@ extension RawSpan {
/// slices, extracted spans do not generally share their indices with the
/// span from which they are extracted.
///
/// This function does not validate `bounds`; this is an unsafe operation.
/// This function may not always 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`.
Expand Down Expand Up @@ -999,7 +998,7 @@ while i < view.count {
}

// ...or:
for i in 0..<view.indices {
for i in 0 ..< view.count {
doSomething(view[i])
}
```
Expand Down