Skip to content
This repository was archived by the owner on Dec 26, 2024. It is now read-only.

Fix clippy hints #6

Merged
merged 1 commit into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ where
/// let mut files = Files::new();
/// let file_id = files.add("test", source);
///
/// assert_eq!(files.source_span(file_id), Span::from_str(source));
/// assert_eq!(files.source_span(file_id), Span::from_string(source));
/// ```
pub fn source_span(&self, file_id: FileId) -> Span {
self.get(file_id).source_span()
Expand Down Expand Up @@ -355,7 +355,7 @@ where
}

pub fn source_span(&self) -> Span {
Span::from_str(self.source.as_ref())
Span::from_string(self.source.as_ref())
}

pub fn source_slice(&self, span: Span) -> Result<&str, Error> {
Expand Down
5 changes: 5 additions & 0 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ impl LineIndex {
}
}

#[allow(clippy::derivable_impls)]
impl Default for LineIndex {
fn default() -> LineIndex {
LineIndex(0)
Expand Down Expand Up @@ -82,6 +83,7 @@ impl fmt::Display for LineNumber {
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct LineOffset(pub RawOffset);

#[allow(clippy::derivable_impls)]
impl Default for LineOffset {
fn default() -> LineOffset {
LineOffset(0)
Expand Down Expand Up @@ -125,6 +127,7 @@ impl ColumnIndex {
}
}

#[allow(clippy::derivable_impls)]
impl Default for ColumnIndex {
fn default() -> ColumnIndex {
ColumnIndex(0)
Expand Down Expand Up @@ -167,6 +170,7 @@ impl fmt::Display for ColumnNumber {
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct ColumnOffset(pub RawOffset);

#[allow(clippy::derivable_impls)]
impl Default for ColumnOffset {
fn default() -> ColumnOffset {
ColumnOffset(0)
Expand Down Expand Up @@ -198,6 +202,7 @@ impl ByteIndex {
}
}

#[allow(clippy::derivable_impls)]
impl Default for ByteIndex {
fn default() -> ByteIndex {
ByteIndex(0)
Expand Down
4 changes: 2 additions & 2 deletions src/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ impl Span {
/// ```rust
/// use codespan::{ByteIndex, Span};
///
/// let span = Span::from_str("hello");
/// let span = Span::from_string("hello");
///
/// assert_eq!(span, Span::new(0, 5));
/// ```
pub fn from_str(s: &str) -> Span {
pub fn from_string(s: &str) -> Span {
Span::new(0, s.len() as u32)
}

Expand Down