Update crate.
Clippy. Fmt.
This commit is contained in:
44
Cargo.lock
generated
44
Cargo.lock
generated
@@ -2,20 +2,20 @@
|
|||||||
name = "piar"
|
name = "piar"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"getopts 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pbr 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"pbr 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "byteorder"
|
name = "byteorder"
|
||||||
version = "1.0.0"
|
version = "1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "getopts"
|
name = "getopts"
|
||||||
version = "0.2.14"
|
version = "0.2.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -29,38 +29,38 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lazy_static"
|
name = "lazy_static"
|
||||||
version = "0.2.2"
|
version = "0.2.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.20"
|
version = "0.2.30"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pbr"
|
name = "pbr"
|
||||||
version = "0.3.1"
|
version = "1.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_syscall"
|
name = "redox_syscall"
|
||||||
version = "0.1.16"
|
version = "0.1.31"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time"
|
name = "time"
|
||||||
version = "0.1.36"
|
version = "0.1.38"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"redox_syscall 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
"redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -75,13 +75,13 @@ version = "0.1.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[metadata]
|
[metadata]
|
||||||
"checksum byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c40977b0ee6b9885c9013cd41d9feffdd22deb3bb4dc3a71d901cc7a77de18c8"
|
"checksum byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff81738b726f5d099632ceaffe7fb65b90212e8dce59d518729e7e8634032d3d"
|
||||||
"checksum getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9047cfbd08a437050b363d35ef160452c5fe8ea5187ae0a624708c91581d685"
|
"checksum getopts 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "65922871abd2f101a2eb0eaebadc66668e54a87ad9c3dd82520b5f86ede5eff9"
|
||||||
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
|
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
|
||||||
"checksum lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6abe0ee2e758cd6bc8a2cd56726359007748fbf4128da998b65d0b70f881e19b"
|
"checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf"
|
||||||
"checksum libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)" = "684f330624d8c3784fb9558ca46c4ce488073a8d22450415c5eb4f4cfb0d11b5"
|
"checksum libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)" = "2370ca07ec338939e356443dac2296f581453c35fe1e3a3ed06023c49435f915"
|
||||||
"checksum pbr 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9f37516f7ab051df67430a6572735d7992fe74dde52554495eec459fb57da41f"
|
"checksum pbr 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e048e3afebb6c454bb1c5d0fe73fda54698b4715d78ed8e7302447c37736d23a"
|
||||||
"checksum redox_syscall 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "8dd35cc9a8bdec562c757e3d43c1526b5c6d2653e23e2315065bc25556550753"
|
"checksum redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "8dde11f18c108289bef24469638a04dce49da56084f2d50618b226e47eb04509"
|
||||||
"checksum time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "211b63c112206356ef1ff9b19355f43740fc3f85960c598a93d3a3d3ba7beade"
|
"checksum time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)" = "d5d788d3aa77bc0ef3e9621256885555368b47bd495c13dd2e7413c89f845520"
|
||||||
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
|
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
|
||||||
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
|
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ authors = ["logaritmisk <anders.e.olsson@gmail.com>"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
getopts = "0.2"
|
getopts = "0.2"
|
||||||
byteorder = "1.0"
|
byteorder = "1.1"
|
||||||
pbr = "0.3"
|
pbr = "1.0"
|
||||||
lazy_static = "0.2"
|
lazy_static = "0.2"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
pub fn get_byte(id: i32) -> u8 {
|
pub fn get_byte(id: i32) -> u8 {
|
||||||
let pid: f64 = 4.0 * series(1, id) - 2.0 * series(4, id) - series(5, id) - series(6, id);
|
let pid: f64 = 4.0 * series(1, id) - 2.0 * series(4, id) - series(5, id) - series(6, id);
|
||||||
|
|
||||||
let y: f64 = (pid - (pid as i32) as f64 + 1.0).abs();
|
let y: f64 = (pid - f64::from(pid as i32) + 1.0).abs();
|
||||||
let y = 16.0 * (y - y.floor());
|
let y = 16.0 * (y - y.floor());
|
||||||
|
|
||||||
((y as u8) << 4) | (16.0 * (y - y.floor())) as u8
|
((y as u8) << 4) | (16.0 * (y - y.floor())) as u8
|
||||||
@@ -15,15 +15,15 @@ fn series(m: i32, id: i32) -> f64 {
|
|||||||
let mut s: f64 = 0.0;
|
let mut s: f64 = 0.0;
|
||||||
|
|
||||||
for k in 0..id {
|
for k in 0..id {
|
||||||
ak = (8 * k + m) as f64;
|
ak = f64::from(8 * k + m);
|
||||||
t = expm((id - k) as f64, ak);
|
t = expm(f64::from(id - k), ak);
|
||||||
|
|
||||||
s += t / ak;
|
s += t / ak;
|
||||||
s -= s.trunc();
|
s -= s.trunc();
|
||||||
}
|
}
|
||||||
|
|
||||||
for k in id..id + 101 {
|
for k in id..id + 101 {
|
||||||
ak = (8 * k + m) as f64;
|
ak = f64::from(8 * k + m);
|
||||||
t = 16f64.powi(id - k) / ak;
|
t = 16f64.powi(id - k) / ak;
|
||||||
|
|
||||||
if t < EPS {
|
if t < EPS {
|
||||||
|
|||||||
1
src/lib.rs
Normal file
1
src/lib.rs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
22
src/main.rs
22
src/main.rs
@@ -1,6 +1,8 @@
|
|||||||
#[macro_use] extern crate lazy_static;
|
|
||||||
extern crate getopts;
|
|
||||||
extern crate byteorder;
|
extern crate byteorder;
|
||||||
|
extern crate getopts;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate lazy_static;
|
||||||
extern crate pbr;
|
extern crate pbr;
|
||||||
|
|
||||||
|
|
||||||
@@ -13,7 +15,7 @@ use std::io::Cursor;
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use getopts::Options;
|
use getopts::Options;
|
||||||
use byteorder::{ReadBytesExt, WriteBytesExt, LittleEndian};
|
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
|
||||||
use pbr::{ProgressBar, Units};
|
use pbr::{ProgressBar, Units};
|
||||||
|
|
||||||
|
|
||||||
@@ -22,20 +24,20 @@ mod bbp;
|
|||||||
|
|
||||||
struct Pi {
|
struct Pi {
|
||||||
next: i32,
|
next: i32,
|
||||||
map: BTreeMap<u8, i32>
|
map: BTreeMap<u8, i32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Pi {
|
impl Pi {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Pi {
|
Pi {
|
||||||
next: 0,
|
next: 0,
|
||||||
map: BTreeMap::new()
|
map: BTreeMap::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find(&mut self, byte: u8) -> i32 {
|
fn find(&mut self, byte: u8) -> i32 {
|
||||||
if self.map.contains_key(&byte) {
|
if self.map.contains_key(&byte) {
|
||||||
*self.map.get(&byte).unwrap()
|
self.map[&byte]
|
||||||
} else {
|
} else {
|
||||||
for i in self.next..i32::MAX {
|
for i in self.next..i32::MAX {
|
||||||
if byte == bbp::get_byte(i) {
|
if byte == bbp::get_byte(i) {
|
||||||
@@ -51,7 +53,7 @@ impl Pi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn print_usage(program: &str, opts: Options) {
|
fn print_usage(program: &str, opts: &Options) {
|
||||||
let brief = format!("Usage: {} [option] INPUT OUTPUT", program);
|
let brief = format!("Usage: {} [option] INPUT OUTPUT", program);
|
||||||
print!("{}", opts.usage(&brief));
|
print!("{}", opts.usage(&brief));
|
||||||
}
|
}
|
||||||
@@ -69,13 +71,13 @@ fn main() {
|
|||||||
let matches = match opts.parse(&args[1..]) {
|
let matches = match opts.parse(&args[1..]) {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
print_usage(&program, opts);
|
print_usage(&program, &opts);
|
||||||
std::process::exit(1);
|
std::process::exit(1)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if matches.opt_present("help") {
|
if matches.opt_present("help") {
|
||||||
print_usage(&program, opts);
|
print_usage(&program, &opts);
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user