@@ -15,8 +15,8 @@ use private::{
1515} ;
1616
1717/// Determines if a code is a valid Open Location Code.
18- pub fn is_valid ( _code : & str ) -> bool {
19- let mut code: String = _code . to_string ( ) ;
18+ pub fn is_valid ( code : & str ) -> bool {
19+ let mut code: String = code . to_string ( ) ;
2020 if code. len ( ) < 3 {
2121 // A code must have at-least a separator character + 1 lat/lng pair
2222 return false ;
@@ -80,8 +80,8 @@ pub fn is_valid(_code: &str) -> bool {
8080///
8181/// A short Open Location Code is a sequence created by removing four or more
8282/// digits from an Open Location Code. It must include a separator character.
83- pub fn is_short ( _code : & str ) -> bool {
84- is_valid ( _code ) && _code . find ( SEPARATOR ) . unwrap ( ) < SEPARATOR_POSITION
83+ pub fn is_short ( code : & str ) -> bool {
84+ is_valid ( code ) && code . find ( SEPARATOR ) . unwrap ( ) < SEPARATOR_POSITION
8585}
8686
8787/// Determines if a code is a valid full Open Location Code.
@@ -91,8 +91,8 @@ pub fn is_short(_code: &str) -> bool {
9191/// and also that the latitude and longitude values are legal. If the prefix
9292/// character is present, it must be the first character. If the separator
9393/// character is present, it must be after four characters.
94- pub fn is_full ( _code : & str ) -> bool {
95- is_valid ( _code ) && !is_short ( _code )
94+ pub fn is_full ( code : & str ) -> bool {
95+ is_valid ( code ) && !is_short ( code )
9696}
9797
9898/// Encode a location into an Open Location Code.
@@ -175,11 +175,11 @@ pub fn encode(pt: Point<f64>, code_length: usize) -> String {
175175///
176176/// Returns a CodeArea object that includes the coordinates of the bounding
177177/// box - the lower left, center and upper right.
178- pub fn decode ( _code : & str ) -> Result < CodeArea , String > {
179- if !is_full ( _code ) {
180- return Err ( format ! ( "Code must be a valid full code: {}" , _code ) ) ;
178+ pub fn decode ( code : & str ) -> Result < CodeArea , String > {
179+ if !is_full ( code ) {
180+ return Err ( format ! ( "Code must be a valid full code: {}" , code ) ) ;
181181 }
182- let mut code = _code
182+ let mut code = code
183183 . to_string ( )
184184 . replace ( SEPARATOR , "" )
185185 . replace ( PADDING_CHAR_STR , "" )
@@ -236,15 +236,15 @@ pub fn decode(_code: &str) -> Result<CodeArea, String> {
236236///
237237/// It returns either the original code, if the reference location was not
238238/// close enough, or the .
239- pub fn shorten ( _code : & str , ref_pt : Point < f64 > ) -> Result < String , String > {
240- if !is_full ( _code ) {
241- return Ok ( _code . to_string ( ) ) ;
239+ pub fn shorten ( code : & str , ref_pt : Point < f64 > ) -> Result < String , String > {
240+ if !is_full ( code ) {
241+ return Ok ( code . to_string ( ) ) ;
242242 }
243- if _code . find ( PADDING_CHAR ) . is_some ( ) {
243+ if code . find ( PADDING_CHAR ) . is_some ( ) {
244244 return Err ( "Cannot shorten padded codes" . to_owned ( ) ) ;
245245 }
246246
247- let codearea: CodeArea = decode ( _code ) . unwrap ( ) ;
247+ let codearea: CodeArea = decode ( code ) . unwrap ( ) ;
248248 if codearea. code_length < MIN_TRIMMABLE_CODE_LEN {
249249 return Err ( format ! (
250250 "Code length must be at least {}" ,
@@ -263,12 +263,12 @@ pub fn shorten(_code: &str, ref_pt: Point<f64>) -> Result<String, String> {
263263 // use 0.3 instead of 0.5 as a multiplier.
264264 let idx = PAIR_RESOLUTIONS . len ( ) - 2 - i;
265265 if range < ( PAIR_RESOLUTIONS [ idx] * 0.3f64 ) {
266- let mut code = _code . to_string ( ) ;
266+ let mut code = code . to_string ( ) ;
267267 code. drain ( ..( ( idx + 1 ) * 2 ) ) ;
268268 return Ok ( code) ;
269269 }
270270 }
271- Ok ( _code . to_string ( ) )
271+ Ok ( code . to_string ( ) )
272272}
273273
274274/// Recover the nearest matching code to a specified location.
@@ -297,18 +297,17 @@ pub fn shorten(_code: &str, ref_pt: Point<f64>) -> Result<String, String> {
297297/// the nearest match, not necessarily the match within the same cell. If the
298298/// passed code was not a valid short code, but was a valid full code, it is
299299/// returned unchanged.
300- pub fn recover_nearest ( _code : & str , ref_pt : Point < f64 > ) -> Result < String , String > {
301- if !is_short ( _code ) {
302- if is_full ( _code ) {
303- return Ok ( _code . to_string ( ) . to_uppercase ( ) ) ;
300+ pub fn recover_nearest ( code : & str , ref_pt : Point < f64 > ) -> Result < String , String > {
301+ if !is_short ( code ) {
302+ if is_full ( code ) {
303+ return Ok ( code . to_string ( ) . to_uppercase ( ) ) ;
304304 } else {
305- return Err ( format ! ( "Passed short code is not valid: {}" , _code ) ) ;
305+ return Err ( format ! ( "Passed short code is not valid: {}" , code ) ) ;
306306 }
307307 }
308308
309- let prefix_len = SEPARATOR_POSITION - _code. find ( SEPARATOR ) . unwrap ( ) ;
310- let mut code = prefix_by_reference ( ref_pt, prefix_len) ;
311- code. push_str ( _code) ;
309+ let prefix_len = SEPARATOR_POSITION - code. find ( SEPARATOR ) . unwrap ( ) ;
310+ let mut code = prefix_by_reference ( ref_pt, prefix_len) + code;
312311
313312 let code_area = decode ( code. as_str ( ) ) . unwrap ( ) ;
314313
0 commit comments