[tor-bugs] #27207 [Core Tor/Tor]: CodingStandardsRust.md is wrong

Tor Bug Tracker & Wiki blackhole at torproject.org
Thu Sep 13 05:36:15 UTC 2018


#27207: CodingStandardsRust.md is wrong
--------------------------+------------------------------------
 Reporter:  cyberpunks    |          Owner:  (none)
     Type:  defect        |         Status:  new
 Priority:  Medium        |      Milestone:  Tor: 0.3.5.x-final
Component:  Core Tor/Tor  |        Version:
 Severity:  Normal        |     Resolution:
 Keywords:  rust, doc     |  Actual Points:
Parent ID:                |         Points:
 Reviewer:                |        Sponsor:
--------------------------+------------------------------------

Comment (by Killer2514):

 Replying to [ticket:27207 cyberpunks]:
 > 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#comment:3>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list