-
Notifications
You must be signed in to change notification settings - Fork 660
Making every type optional via Option #4406
Conversation
✅ Deploy Preview for docs-rometools canceled.Built without sensitive environment variables
|
@2022H1030042G have you tried running |
crates/rome_formatter/src/lib.rs
Outdated
@@ -83,7 +83,7 @@ pub enum IndentStyle { | |||
#[default] | |||
Tab, | |||
/// Space, with its quantity | |||
Space(u8), | |||
Space(Option<u8>), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need to change. You can revert the change
@@ -74,7 +74,7 @@ impl PrinterOptions { | |||
pub(super) const fn indent_width(&self) -> u8 { | |||
match self.indent_style { | |||
IndentStyle::Tab => self.tab_width, | |||
IndentStyle::Space(count) => count, | |||
IndentStyle::Space(Option<count>) => count, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can revert the change here
@@ -153,7 +153,7 @@ struct IrFormatOptions; | |||
|
|||
impl FormatOptions for IrFormatOptions { | |||
fn indent_style(&self) -> IndentStyle { | |||
IndentStyle::Space(2) | |||
IndentStyle::Space(Some(2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can revert the change
@@ -165,7 +165,7 @@ impl FormatOptions for IrFormatOptions { | |||
tab_width: 2, | |||
print_width: self.line_width().into(), | |||
line_ending: LineEnding::LineFeed, | |||
indent_style: IndentStyle::Space(2), | |||
indent_style: IndentStyle::Space(Some(2)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can revert the change
Some(PlainIndentStyle::Tab) => IndentStyle::Tab, | ||
Some(PlainIndentStyle::Space) => IndentStyle::Space(conf.indent_size), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some(PlainIndentStyle::Tab) => IndentStyle::Tab, | |
Some(PlainIndentStyle::Space) => IndentStyle::Space(conf.indent_size), | |
Some(PlainIndentStyle::Tab) => IndentStyle::Tab, | |
Some(PlainIndentStyle::Space) => IndentStyle::Space(conf.indent_size), | |
None => IndentStyle::Tab |
where | ||
D: serde::de::Deserializer<'de>, | ||
{ | ||
let value: u16 = Deserialize::deserialize(deserializer)?; | ||
LineWidth::try_from(value).map_err(serde::de::Error::custom) | ||
Option::<LineWidth>::try_from(value).map_err(serde::de::Error::custom) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Option::<LineWidth>::try_from(value).map_err(serde::de::Error::custom) | |
let line_width = LineWidth::try_from(value).map_err(serde::de::Error::custom)?; | |
Ok(Some(line_width)) |
After performing the above changes, there are still errors. PFA |
You can push the changes :) no need to attach any files! |
Done. Will you be looking into it? |
Hi @2022H1030042G, I thought you had some basic knowledge of Rust. I needed this feature for #4405 and eventually did it myself there. Thank you for your contribution. I am going to create some new good first issues that don't require priority from our end! |
Refer: #4399
Summary
Test Plan
Changelog
Documentation