Skip to content
This repository has been archived by the owner on May 18, 2024. It is now read-only.

Specifying offset and size #2

Closed
gravit0 opened this issue Apr 7, 2018 · 1 comment
Closed

Specifying offset and size #2

gravit0 opened this issue Apr 7, 2018 · 1 comment

Comments

@gravit0
Copy link

gravit0 commented Apr 7, 2018

atoi_end does not allow you to specify the offset size, which limits the scope
New API Example:

fn main() {

	let array_end = b"xza1245ssfsadfasdasd";

	let my_int = u64::atoi_end(array_end, 3u16, 4u16).unwrap(); //1245u64

}
@denisandroid
Copy link
Member

Hi, why do not you try

fn main() {
	let array = b"xza1245ssfsadfasdasd";
	
	let my_int = u64::atoi(&array[3..3 + 4]).unwrap(); //1245u64
	println!("{}", my_int);
}

Or:


fn main() {
	let array = b"xza1245ssfsadfasdasd";
	
	let my_int = u64::atoi_iter(&mut array.iter().skip(3).take(4)).unwrap(); //1245u64
	
	println!("{}", my_int);
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants