Fix clippy.
This commit is contained in:
parent
7d73a3c948
commit
8d85d5ef79
@ -55,7 +55,7 @@ render!(RenderSrcBlock, ISrcBlock, original, render_context, {
|
|||||||
RenderSrcLine { children }
|
RenderSrcLine { children }
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
match original.language.as_ref().map(String::as_str) {
|
match original.language.as_deref() {
|
||||||
Some("bash") => {
|
Some("bash") => {
|
||||||
render_context
|
render_context
|
||||||
.dependency_manager
|
.dependency_manager
|
||||||
|
@ -32,6 +32,7 @@ pub(crate) struct IRealFootnoteDefinition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl IRealFootnoteDefinition {
|
impl IRealFootnoteDefinition {
|
||||||
|
#[allow(clippy::needless_lifetimes)]
|
||||||
pub(crate) async fn new<'orig, 'parse>(
|
pub(crate) async fn new<'orig, 'parse>(
|
||||||
_intermediate_context: IntermediateContext<'orig, 'parse>,
|
_intermediate_context: IntermediateContext<'orig, 'parse>,
|
||||||
footnote_id: usize,
|
footnote_id: usize,
|
||||||
|
@ -9,6 +9,7 @@ macro_rules! inoop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl $istruct {
|
impl $istruct {
|
||||||
|
#[allow(clippy::extra_unused_lifetimes)]
|
||||||
pub(crate) async fn new<'reg, 'orig, 'parse>(
|
pub(crate) async fn new<'reg, 'orig, 'parse>(
|
||||||
_intermediate_context: crate::intermediate::IntermediateContext<'orig, 'parse>,
|
_intermediate_context: crate::intermediate::IntermediateContext<'orig, 'parse>,
|
||||||
original: &'orig organic::types::$pstruct<'parse>,
|
original: &'orig organic::types::$pstruct<'parse>,
|
||||||
|
@ -31,6 +31,7 @@ intermediate!(
|
|||||||
);
|
);
|
||||||
|
|
||||||
impl IParagraph {
|
impl IParagraph {
|
||||||
|
#[allow(clippy::needless_lifetimes)]
|
||||||
pub(crate) async fn artificial<'orig, 'parse>(
|
pub(crate) async fn artificial<'orig, 'parse>(
|
||||||
_intermediate_context: crate::intermediate::IntermediateContext<'orig, 'parse>,
|
_intermediate_context: crate::intermediate::IntermediateContext<'orig, 'parse>,
|
||||||
children: Vec<IObject>,
|
children: Vec<IObject>,
|
||||||
@ -50,19 +51,19 @@ impl IParagraph {
|
|||||||
.children
|
.children
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|c| match c {
|
.filter(|c| match c {
|
||||||
IObject::RegularLink(iregular_link) => match &iregular_link.target {
|
IObject::RegularLink(iregular_link) => matches!(
|
||||||
super::LinkTarget::Image { src: _, alt: _ } => true,
|
&iregular_link.target,
|
||||||
_ => false,
|
super::LinkTarget::Image { src: _, alt: _ }
|
||||||
},
|
),
|
||||||
_ => false,
|
_ => false,
|
||||||
})
|
})
|
||||||
.count();
|
.count();
|
||||||
num_images == 1
|
num_images == 1
|
||||||
&& self.children.iter().all(|c| match c {
|
&& self.children.iter().all(|c| match c {
|
||||||
IObject::RegularLink(iregular_link) => match &iregular_link.target {
|
IObject::RegularLink(iregular_link) => matches!(
|
||||||
super::LinkTarget::Image { src: _, alt: _ } => true,
|
&iregular_link.target,
|
||||||
_ => false,
|
super::LinkTarget::Image { src: _, alt: _ }
|
||||||
},
|
),
|
||||||
IObject::PlainText(iplain_text) => {
|
IObject::PlainText(iplain_text) => {
|
||||||
iplain_text.source.chars().all(|c| c.is_ascii_whitespace())
|
iplain_text.source.chars().all(|c| c.is_ascii_whitespace())
|
||||||
}
|
}
|
||||||
|
@ -180,6 +180,7 @@ async fn convert_definition_contents<'orig, 'parse>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Take a footnote definition that has not yet received a reference and move it into the active footnotes.
|
/// Take a footnote definition that has not yet received a reference and move it into the active footnotes.
|
||||||
|
#[allow(clippy::needless_lifetimes)]
|
||||||
pub(crate) async fn promote_footnote_definition<'orig, 'parse>(
|
pub(crate) async fn promote_footnote_definition<'orig, 'parse>(
|
||||||
intermediate_context: IntermediateContext<'orig, 'parse>,
|
intermediate_context: IntermediateContext<'orig, 'parse>,
|
||||||
label: &'parse str,
|
label: &'parse str,
|
||||||
|
@ -186,7 +186,7 @@ impl LinkTarget {
|
|||||||
if path.is_absolute() {
|
if path.is_absolute() {
|
||||||
return Ok(format!("file://{}", input));
|
return Ok(format!("file://{}", input));
|
||||||
}
|
}
|
||||||
return Ok(input.into_owned());
|
Ok(input.into_owned())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get file name from the last segment of an image path.
|
/// Get file name from the last segment of an image path.
|
||||||
@ -199,7 +199,7 @@ impl LinkTarget {
|
|||||||
let path = Path::new(input.as_ref());
|
let path = Path::new(input.as_ref());
|
||||||
match path
|
match path
|
||||||
.components()
|
.components()
|
||||||
.last()
|
.next_back()
|
||||||
.ok_or("Images should have at least one component in their path.")?
|
.ok_or("Images should have at least one component in their path.")?
|
||||||
{
|
{
|
||||||
std::path::Component::Prefix(_) => {
|
std::path::Component::Prefix(_) => {
|
||||||
@ -209,9 +209,7 @@ impl LinkTarget {
|
|||||||
std::path::Component::RootDir
|
std::path::Component::RootDir
|
||||||
| std::path::Component::CurDir
|
| std::path::Component::CurDir
|
||||||
| std::path::Component::ParentDir => {
|
| std::path::Component::ParentDir => {
|
||||||
return Err(
|
Err("Final component of an image path should be a normal component.".into())
|
||||||
"Final component of an image path should be a normal component.".into(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
std::path::Component::Normal(file_name) => Ok(file_name
|
std::path::Component::Normal(file_name) => Ok(file_name
|
||||||
.to_str()
|
.to_str()
|
||||||
@ -236,6 +234,7 @@ mod tests {
|
|||||||
let registry = Registry::new();
|
let registry = Registry::new();
|
||||||
let registry = Arc::new(Mutex::new(registry));
|
let registry = Arc::new(Mutex::new(registry));
|
||||||
let intermediate_context = IntermediateContext::new(registry)?;
|
let intermediate_context = IntermediateContext::new(registry)?;
|
||||||
|
#[allow(clippy::single_element_loop)]
|
||||||
for (inp, typ) in [(
|
for (inp, typ) in [(
|
||||||
"https://test.example/foo",
|
"https://test.example/foo",
|
||||||
LinkType::Protocol(Cow::from("https")),
|
LinkType::Protocol(Cow::from("https")),
|
||||||
|
@ -77,7 +77,7 @@ intermediate!(
|
|||||||
.collect();
|
.collect();
|
||||||
let language = original.language.map(str::to_owned);
|
let language = original.language.map(str::to_owned);
|
||||||
|
|
||||||
match language.as_ref().map(String::as_str) {
|
match language.as_deref() {
|
||||||
Some(lang @ "bash") => {
|
Some(lang @ "bash") => {
|
||||||
let highlighted = highlight_bash(&lines);
|
let highlighted = highlight_bash(&lines);
|
||||||
if let Ok(highlighted) = highlighted {
|
if let Ok(highlighted) = highlighted {
|
||||||
@ -151,7 +151,7 @@ where
|
|||||||
std::string::String: for<'a> From<&'a L>,
|
std::string::String: for<'a> From<&'a L>,
|
||||||
{
|
{
|
||||||
Ok(lines
|
Ok(lines
|
||||||
.into_iter()
|
.iter()
|
||||||
.map(|l| {
|
.map(|l| {
|
||||||
let mut line = ISrcLine::new();
|
let mut line = ISrcLine::new();
|
||||||
line.children.push(ISrcSegment::RawText(l.into()));
|
line.children.push(ISrcSegment::RawText(l.into()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user