Skip to content

Instantly share code, notes, and snippets.

@marcusklaas
Created October 3, 2015 20:49
Show Gist options
  • Save marcusklaas/f3a5266f75e1bcb6dd7e to your computer and use it in GitHub Desktop.
Save marcusklaas/f3a5266f75e1bcb6dd7e to your computer and use it in GitHub Desktop.
pub trait AsRev {
fn as_rev(&self) -> &ListItem;
}
impl AsRev for ListItem {
fn as_rev(&self) -> &ListItem {
&self
}
}
impl<'a> AsRev for &'a ListItem {
fn as_rev(&self) -> &ListItem {
self
}
}
pub struct ListItem {
pub pre_comment: Option<String>,
// Item should include attributes and doc comments.
pub item: String,
pub post_comment: Option<String>,
// Whether there is extra whitespace before this item.
pub new_lines: bool,
}
pub fn definitive_tactic<'t, I, T>(items: I,
tactic: ListTactic,
width: usize)
-> DefinitiveListTactic
where I: IntoIterator<Item = T> + Clone,
T: AsRev
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment