import std.range : cycle, take, drop;
import std.algorithm : copy;
ubyte[n] rotateRight(size_t n)(ref const ubyte[n] array, uint rotation){
.drop(n - (rotation / 8) % n)
const ubyte bit_rotation = rotation % 8;
enum ubyte full = 0b1111_1111;
ubyte next_prefix(const ubyte elm){
const ubyte suffix = (elm & ~(full << bit_rotation));
const ubyte prefix = cast(ubyte)(suffix << (8 - bit_rotation));
ubyte prefix = next_prefix(result[$-1]);
foreach(ref ubyte elm; result[]){
const new_prefix = next_prefix(elm);
elm = (elm >> bit_rotation) | prefix;
writefln!"%(%8b,\n%)"(x.rotateRight(4));