bs_crate 0.1.2

The palindrome numbers library
Documentation

Rust take-home assignment

Definitions

A "palindrome" is a number that is the same when the digits are reversed. For example, 121, 2332, and 6 are all palindromes. But 10 is not a palindrome (since leading zeroes are not allowed). Treat 0 as a palindrome, and use an unsigned integer type.

Goal

Write crate that allows the user to:

  1. check if a number is a palindrome
  2. generate the first N palindromes

Assumptions

  1. No need to deal with numbers greater than 1,000,000.
  2. Code may panic if it is called with any values that would result in a number greater than 1,000,000 being generated.
  3. 3rd-party crates can be used, but they may not appear in your public API.

Constrains

If a crate literally implements the question as-is, don't use it.

Abstract

The main focus of the exercise is to develop a high-quality crate. The exact meaning of "high-quality" is left deliberately vague, but use your best judgement. Think about the crates you've had the best experience with, and try to emulate those. The exact details of the API are up to you - there are no hard requirements about function signatures, etc (other than there being no 3rd-party types present in the API).

Code location

There are two ways to use the palindrome library:

  1. The code can be cloned from the github.com:
> git clone https://github.com/binspammer/palindrome.git

and and the crate can be taked from bs_crate directly.

  1. Or it can be just used directly from crates.io:

Using

The crate should be used like this:

use bs_crate;

fn main() {
    let x = 123;
    let is_palindrome = bs_crate::is_palindrome(x);
    println!("{x} is a palindrome: {is_palindrome}");

    let first_10_palindromes = bs_crate::first_n_palindromes(10);

    for x in first_10_palindromes {
        println!("{x} is a palindrome");
    }
}