Seems like this could be something in the stdlib. Have you thought about trying to get this in the Crystal Compiler?