[tor-bugs] #27207 [Core Tor/Tor]: CodingStandardsRust.md is wrong
Tor Bug Tracker & Wiki
blackhole at torproject.org
Sun Aug 19 18:44:53 UTC 2018
#27207: CodingStandardsRust.md is wrong
------------------------------+-----------------------
Reporter: cyberpunks | Owner: (none)
Type: defect | Status: new
Priority: Medium | Milestone:
Component: Core Tor/Tor | Version:
Severity: Normal | Keywords: rust, doc
Actual Points: | Parent ID:
Points: | Reviewer:
Sponsor: |
------------------------------+-----------------------
The section on `CString` is incorrect:
- `CString::new("bl\x00ah").unwrap().into_raw()` will panic in the
'unwrap' call, it will never return a pointer of any kind, dangling or
otherwise.
Also,
[https://gitweb.torproject.org/tor.git/commit/doc/HACKING/CodingStandardsRust.md?id=12cf04646c571646b726e697d66ecafad7886cf2
12cf04646c571646b726e697d66ecafad7886cf2] seems to be the result of some
miscommunication with [https://github.com/withoutboats withoutboats]:
- `.expect()` is [https://doc.rust-
lang.org/std/result/enum.Result.html#method.expect literally]
'`.unwrap()`, but with a custom panic message,' it doesn't return an
`Option` and is no safer than unwrap, but it is self-documenting.
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/27207>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the tor-bugs
mailing list