Uh oh!
There was an error while loading. Please reload this page.
[RFC] num: bitwise reflection methods - #13209
Conversation
Let Bitwise provide a reflect() method for reversed binary representation. This is a binary primitive used in several algorithms, eg. CRC checksums. Signed-off-by: Luca Bruno <lucab@debian.org>
bill-myers
commented
Mar 30, 2014
The operation for bytes is usually called "byteswap", so maybe this could be called "bitswap", although someone might confuse bits and bytes. Alternatively, "reverse_bits", or something like that. Anyway, the implementation in this pull request is terrible; see http://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel for the proper way to do it. |
alexcrichton
commented
Mar 30, 2014
@bill-myers, please keep the third point of our code of conduct in mind. Blatant insults will not be tolerated. |
lucab
commented
Mar 30, 2014
@bill-myers yes, it is a naïve O(n) implementation and it would as well make sense to move to a logarithmic one, trading a bit of clarity/simpllcity. However, as said, I have some other doubts about this PR and it may as well end being scrapped, so it's raw and far from being final. |
alexcrichton
commented
Apr 15, 2014
How about naming the method |
alexcrichton
commented
Apr 23, 2014
Closing due to inactivity, but feel free to reopen with a rebase! |
…Veykril
feat: type inference for generators
This PR implements basic type inference for generator and yield expressions.
Things not included in this PR:
- Generator upvars and generator witnesses are not implemented. They are only used to determine auto trait impls, so basic type inference should be fine without them, but method resolutions with auto trait bounds may not be resolved correctly.
Open questions:
- I haven't (yet) implemented `HirDisplay` for `TyKind::Generator`, so generator types are just shown as "{{generator}}" (in tests, inlay hints, hovers, etc.), which is not really nice. How should we show them?
- I added moderate amount of stuffs to minicore. I especially didn't want to add `impl<T> Deref for &T` and `impl<T> Deref for &mut T` exclusively for tests for generators; should I move them into the test fixtures or can they be placed in minicore?
cc rust-lang#4309…r=y21 Limit number of `nonminimal_bool` ops Fixesrust-lang/rust-clippy#11257Fixesrust-lang/rust-clippy#13206 changelog: none
A bit-manipulation PR, however I still have some doubts:
reflect()too generic? That's how the operation is usually called, but may be too broad as API and conflict with reflection/introspection.Bitwisetrait lacksOne,ZeroandNumCastfor this implementation to work. Maybe they should be added anyway?impl Bitwise for i8..i64in multiple files? Most of it is through instrinsics in each module, but ideallyreflect()could be directly implemented in uint/int_macros abusing$T.Let Bitwise provide a reflect() method for reversed binary
representation. This is a binary primitive used in several algorithms,
eg. CRC checksums.