mirror of
https://github.com/astral-sh/ruff
synced 2026-01-22 14:00:51 -05:00
Fix a few nursery rule violations (#2548)
This commit is contained in:
@@ -57,8 +57,12 @@ impl<'a> From<&'a Stylist<'a>> for Generator<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Generator<'a> {
|
||||
pub fn new(indent: &'a Indentation, quote: &'a Quote, line_ending: &'a LineEnding) -> Self {
|
||||
Generator {
|
||||
pub const fn new(
|
||||
indent: &'a Indentation,
|
||||
quote: &'a Quote,
|
||||
line_ending: &'a LineEnding,
|
||||
) -> Self {
|
||||
Self {
|
||||
// Style preferences.
|
||||
indent,
|
||||
quote,
|
||||
|
||||
@@ -93,8 +93,8 @@ fn truncate(location: Location, index: &Index, contents: &str) -> usize {
|
||||
}
|
||||
|
||||
impl<'a> Locator<'a> {
|
||||
pub fn new(contents: &'a str) -> Self {
|
||||
Locator {
|
||||
pub const fn new(contents: &'a str) -> Self {
|
||||
Self {
|
||||
contents,
|
||||
index: OnceCell::new(),
|
||||
}
|
||||
@@ -140,11 +140,11 @@ impl<'a> Locator<'a> {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn len(&self) -> usize {
|
||||
pub const fn len(&self) -> usize {
|
||||
self.contents.len()
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
pub const fn is_empty(&self) -> bool {
|
||||
self.contents.is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ impl From<&Quote> for char {
|
||||
pub struct Indentation(String);
|
||||
|
||||
impl Indentation {
|
||||
pub fn new(indentation: String) -> Self {
|
||||
pub const fn new(indentation: String) -> Self {
|
||||
Self(indentation)
|
||||
}
|
||||
}
|
||||
@@ -142,7 +142,7 @@ impl Default for LineEnding {
|
||||
}
|
||||
|
||||
impl LineEnding {
|
||||
pub fn as_str(&self) -> &'static str {
|
||||
pub const fn as_str(&self) -> &'static str {
|
||||
match self {
|
||||
LineEnding::CrLf => "\r\n",
|
||||
LineEnding::Lf => "\n",
|
||||
|
||||
Reference in New Issue
Block a user