A .sq() function for std::num::Float?
Nobody has claimed this yet.
- Dominant language
- Markdown
- Stars
- 6.6k
- Forks
- 1.7k
- Avg merge
- 16h 14m
- Merged PRs (30d)
- 1
Description
For a lot of things, it feels strange to have a .sqrt() function and no .sq(). I understand that .sqrt() isn't trivial to implement yourself while .sq() very much is, but at the same time having to do things like .powi(2) or let x: ...; x*x makes the end result a lot less immediately obvious. It's not helped by the fact that powi is a slightly confusing name.
Calculating the distance between to points is an example of where a .sq() would be nice. Without it, it becomes either:
((x1 - x2).powi(2) + (y1 - y2).powi(2)).sqrt()
Or:
let x = x1 - x2;
let y = y1 - y2;
(x*x + y*y).sqrt()
The ability to just be able to write this would be a lot nicer and a lot clearer:
((x1 - x2).sq() + (y1 - y2).sq()).sqrt()
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue proposes adding .sq() to std::num::Float but names no implementation file, entry point, or test. Start by reviewing the existing Float API and the RFC repository process; done means the API proposal has a settled design and an agreed implementation path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100