[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

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



#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
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs