Spaceship operator always returns strong_ordering
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
The spaceship operator is currently lowered to Ord::cmp in the C++-to-Rust translation pass, so start by finding where binary <=> is handled in the Clang AST visitor and the matching Rust emission code. The issue asks for a ThreeWayComparable-style trait so the result category follows the operand types, including partial_ordering for floats and the weakest-member rule for std::pair. Done means 1.0 <=> 2.0 and pair{NAN, 1} < pair{NAN, 2} translate with the correct ordering semantics and have tests covering them.
由索引模型根據 Issue 內容生成。
描述
a <=> b is translated as Ord::cmp, which always gives Ordering (strong_ordering). In C++ the result depends on the operands:
1 <=> 2 // strong_ordering
1.0 <=> NAN // partial_ordering (unordered)
w1 <=> w2 // weak_ordering, if W's operator<=> returns it
So 1.0 <=> 2.0 does not compile, and a weak ordering becomes strong.
std::pair's operator<=> returns the weakest category of its members (pair<double, int> gives partial_ordering). Its rule is generic, so without a trait for <=> it can only compare the members with < and return Ordering, and pair{NAN, 1} < pair{NAN, 2} is true instead of false.
We need to translate spaceship operator to a ThreeWayComparable trait.
- 主要語言
- Rust
- 星號
- 310
- 分支
- 18
- 平均合併
- 9 小時 46 分鐘
- 30 天內合併 PR
- 82
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
Cpp2Rust/cpp2rust 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 79/100
Cpp2Rust/cpp2rust#610 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 15/100
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 22/100
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 35/100
Cpp2Rust/cpp2rust#674 · 1 則留言 ·
維護者通常 1 天內回覆
查看 Cpp2Rust/cpp2rust 的全部 Issue
相似的 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 69/100
維護者通常 1 天內回覆
-
test_a_503_raises_unavailable_error fails on macOS about one run in six可能已有人在做 @naman-modi 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
bug ui
難度 2/5 1-3 小時 新手友好度 72/100
userFRM/egui-charts#4168 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 85/100
維護者通常 1 天內回覆