File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -142,6 +142,13 @@ impl<T: Copy + fmt::Debug> fmt::Debug for VarLenArray<T> {
142142 }
143143}
144144
145+ // Safety: `VarLenArray` allocates and frees memory for its data, which is copied
146+ // from its original location; it never holds a reference to the data used to create it.
147+ // Therefore if `T` is Send, so is `VarLenArray<T>`
148+ unsafe impl < T : Copy + Send > Send for VarLenArray < T > { }
149+ // Safety: No interior mutability or potential for data races if `T` is `Sync`.
150+ unsafe impl < T : Copy + Sync > Sync for VarLenArray < T > { }
151+
145152#[ cfg( test) ]
146153pub mod tests {
147154 use super :: VarLenArray ;
Original file line number Diff line number Diff line change @@ -282,6 +282,12 @@ impl AsAsciiStr for VarLenAscii {
282282 }
283283}
284284
285+ // Safety: `VarLenAscii` allocates and frees memory for its data, which is copied
286+ // from its original location; it never holds a reference to the data used to create it.
287+ unsafe impl Send for VarLenAscii { }
288+ // Safety: No interior mutability or potential for data races.
289+ unsafe impl Sync for VarLenAscii { }
290+
285291// ================================================================================
286292
287293#[ repr( C ) ]
@@ -371,6 +377,12 @@ impl FromStr for VarLenUnicode {
371377 }
372378}
373379
380+ // Safety: `VarLenUnicode` allocates and frees memory for its data, which is copied
381+ // from its original location; it never holds a reference to the data used to create it.
382+ unsafe impl Send for VarLenUnicode { }
383+ // Safety: No interior mutability or potential for data races.
384+ unsafe impl Sync for VarLenUnicode { }
385+
374386// ================================================================================
375387
376388#[ repr( C ) ]
You can’t perform that action at this time.
0 commit comments