Skip to content

Commit a0760ed

Browse files
authored
Merge pull request #12 from kakalos12/marirs-main
remove &mut some places
2 parents 96c5e02 + 9919494 commit a0760ed

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

examples/lookup.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ use ip2location::DB;
44

55
fn main() -> Result<(), String> {
66
let mut args = std::env::args().skip(1);
7-
let mut db = match DB::from_file(
8-
&*args
9-
.next()
10-
.ok_or("First argument is the path to db")?,
11-
) {
7+
let db = match DB::from_file(&*args.next().ok_or("First argument is the path to db")?) {
128
Ok(db) => db,
139
Err(e) => {
1410
println!("{:?}", e);

src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl DB {
131131
}
132132
}
133133

134-
pub fn ip_lookup(&mut self, ip: IpAddr) -> Result<Record, Error> {
134+
pub fn ip_lookup(&self, ip: IpAddr) -> Result<Record, Error> {
135135
//! Lookup for the given IPv4 or IPv6 and returns the
136136
//! Geo information or Proxy Information
137137
//!

src/tests/tests_lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const IP2PROXYBIN: &str = "data/IP2PROXY-IP-COUNTRY.BIN";
66

77
#[test]
88
fn test_ipv4_lookup_in_ipv4bin() -> Result<(), error::Error> {
9-
let mut db = DB::from_file(IPV4BIN)?;
9+
let db = DB::from_file(IPV4BIN)?;
1010
let record = db.ip_lookup("43.224.159.155".parse().unwrap())?;
1111
let record = if let Record::LocationDb(rec) = record {
1212
Some(rec)
@@ -23,7 +23,7 @@ fn test_ipv4_lookup_in_ipv4bin() -> Result<(), error::Error> {
2323

2424
#[test]
2525
fn test_ipv4_lookup_in_ipv6bin() -> Result<(), error::Error> {
26-
let mut db = DB::from_file(IPV6BIN)?;
26+
let db = DB::from_file(IPV6BIN)?;
2727
let record = db.ip_lookup("43.224.159.155".parse().unwrap())?;
2828
let record = if let Record::LocationDb(rec) = record {
2929
Some(rec)
@@ -40,7 +40,7 @@ fn test_ipv4_lookup_in_ipv6bin() -> Result<(), error::Error> {
4040

4141
#[test]
4242
fn test_ipv6_lookup() -> Result<(), error::Error> {
43-
let mut db = DB::from_file(IPV6BIN)?;
43+
let db = DB::from_file(IPV6BIN)?;
4444
let record = db.ip_lookup("2a01:b600:8001::".parse().unwrap())?;
4545
let record = if let Record::LocationDb(rec) = record {
4646
Some(rec)
@@ -68,7 +68,7 @@ fn test_err_filenotfound_location() -> Result<(), error::Error> {
6868

6969
#[test]
7070
fn test_ip_lookup_in_proxy_bin() -> Result<(), error::Error> {
71-
let mut db = DB::from_file(IP2PROXYBIN)?;
71+
let db = DB::from_file(IP2PROXYBIN)?;
7272
let record = db.ip_lookup("1.1.1.1".parse().unwrap())?;
7373
let record = if let Record::ProxyDb(rec) = record {
7474
Some(rec)

0 commit comments

Comments
 (0)