Skip to content

Commit 0423654

Browse files
committed
Appease Clippy
1 parent 318e514 commit 0423654

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

src/lib.rs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ impl Log for AndroidLogger {
151151

152152
// If no tag was specified, use module name
153153
let custom_tag = &config.tag;
154-
let tag = custom_tag.as_ref().map(|s| s.as_bytes()).unwrap_or(module_path.as_bytes());
154+
let tag = custom_tag.as_ref().map(|s| s.as_bytes()).unwrap_or_else(|| module_path.as_bytes());
155155

156156
// truncate the tag here to fit into LOGGING_TAG_MAX_LEN
157157
self.fill_tag_bytes(&mut tag_bytes, tag);
@@ -202,24 +202,14 @@ impl AndroidLogger {
202202
}
203203

204204
/// Filter for android logger.
205+
#[derive(Default)]
205206
pub struct Config {
206207
log_level: Option<Level>,
207208
filter: Option<env_logger::filter::Filter>,
208209
tag: Option<CString>,
209210
custom_format: Option<FormatFn>,
210211
}
211212

212-
impl Default for Config {
213-
fn default() -> Self {
214-
Config {
215-
log_level: None,
216-
filter: None,
217-
tag: None,
218-
custom_format: None,
219-
}
220-
}
221-
}
222-
223213
impl Config {
224214
/// Change the minimum log level.
225215
///
@@ -232,7 +222,7 @@ impl Config {
232222

233223
fn filter_matches(&self, record: &Record) -> bool {
234224
if let Some(ref filter) = self.filter {
235-
filter.matches(&record)
225+
filter.matches(record)
236226
} else {
237227
true
238228
}
@@ -361,7 +351,7 @@ impl<'a> PlatformLogWriter<'a> {
361351

362352
/// Copy `len` bytes from `index` position to starting position.
363353
fn copy_bytes_to_start(&mut self, index: usize, len: usize) {
364-
let src = unsafe { self.buffer.as_ptr().offset(index as isize) };
354+
let src = unsafe { self.buffer.as_ptr().add(index) };
365355
let dst = self.buffer.as_mut_ptr();
366356
unsafe { ptr::copy(src, dst, len) };
367357
}
@@ -524,7 +514,7 @@ mod tests {
524514
fn platform_log_writer_init_values() {
525515
let tag = CStr::from_bytes_with_nul(b"tag\0").unwrap();
526516

527-
let writer = PlatformLogWriter::new(Level::Warn, &tag);
517+
let writer = PlatformLogWriter::new(Level::Warn, tag);
528518

529519
assert_eq!(writer.tag, tag);
530520
// Android uses LogPriority instead, which doesn't implement equality checks
@@ -623,6 +613,6 @@ mod tests {
623613
}
624614

625615
fn get_tag_writer() -> PlatformLogWriter<'static> {
626-
PlatformLogWriter::new(Level::Warn, &CStr::from_bytes_with_nul(b"tag\0").unwrap())
616+
PlatformLogWriter::new(Level::Warn, CStr::from_bytes_with_nul(b"tag\0").unwrap())
627617
}
628618
}

0 commit comments

Comments
 (0)