Crates.io | trid |
lib.rs | trid |
version | 5.0.0 |
source | src |
created_at | 2022-04-10 05:39:14.833237 |
updated_at | 2023-05-27 03:59:10.495692 |
description | Turkish citizenship ID number type |
homepage | https://github.com/ssg/trid |
repository | https://github.com/ssg/trid |
max_upload_size | |
id | 564973 |
size | 16,787 |
This is my first ever written Rust code derived from my own TurkishId package for .NET. I'm trying to use existing code as an excuse to learn about Rust. Despite constant tackling with error messages, Rust has been extremely impressive so far. (How cool are doc-tests!?)
The crate provides TurkishId
type that represents a valid Turkish ID number. It can be instantiated
from a string using the parse()
method of str
type. TurkishId
type guarantess that it never contains an invalid Turkish ID number, so there's no need to validate a TurkishId
once parsed. It
can always be passed around.
The crate also provides is_valid(value: &str)
function for validating ID numbers.
The type occupies 11 bytes in memory and kept as ASCII representation of the number.
Validate a Turkish citizenship ID number:
if trid::is_valid("12345678901") {
// yayyy!
}
Try parsing a string into TurkishId
:
use trid::TurkishId;
let id : TurkishId = "12345678901".parse()?;
Apache License Version 2.0, see LICENSE file for details.