Mark tor_netdoc::err::Pos as Send and Sync

I am about 99% sure this is safe: the pointer that this type
contains is never dereferenced, and is only compared to the bounds
of a string later on.
This commit is contained in:
Nick Mathewson 2020-11-11 09:57:07 -05:00
parent c440f4d476
commit 136c536123
1 changed files with 9 additions and 0 deletions

View File

@ -46,6 +46,15 @@ pub enum Pos {
},
}
// It's okay to send a Pos to another thread, even though its Raw
// variant contains a pointer. That's because we never dereference the
// pointer: we only compare it to another pointer representing a
// string.
//
// TODO: Find a better way to have Pos work.
unsafe impl Send for Pos {}
unsafe impl Sync for Pos {}
impl Pos {
/// Construct a Pos from an offset within a &str slice.
pub fn from_offset(s: &str, off: usize) -> Self {