Struct git_mailmap::Entry
source · pub struct Entry<'a> { /* private fields */ }Expand description
An typical entry of a mailmap, which always contains an old_email by which
the mapping is performed to replace the given new_name and new_email.
Optionally, old_name is also used for lookup.
Typically created by parse().
Implementations§
source§impl<'a> Entry<'a>
impl<'a> Entry<'a>
Constructors indicating what kind of mapping is created.
Only these combinations of values are valid.
sourcepub fn change_name_by_email(
proper_name: impl Into<&'a BStr>,
commit_email: impl Into<&'a BStr>
) -> Self
pub fn change_name_by_email(
proper_name: impl Into<&'a BStr>,
commit_email: impl Into<&'a BStr>
) -> Self
Examples found in repository?
src/parse.rs (line 71)
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
fn parse_line(line: &BStr, line_number: usize) -> Result<Entry<'_>, Error> {
let (name1, email1, rest) = parse_name_and_email(line, line_number)?;
let (name2, email2, rest) = parse_name_and_email(rest, line_number)?;
if !rest.trim().is_empty() {
return Err(Error::UnconsumedInput {
line_number,
line: line.into(),
});
}
Ok(match (name1, email1, name2, email2) {
(Some(proper_name), Some(commit_email), None, None) => Entry::change_name_by_email(proper_name, commit_email),
(None, Some(proper_email), None, Some(commit_email)) => {
Entry::change_email_by_email(proper_email, commit_email)
}
(Some(proper_name), Some(proper_email), None, Some(commit_email)) => {
Entry::change_name_and_email_by_email(proper_name, proper_email, commit_email)
}
(Some(proper_name), Some(proper_email), Some(commit_name), Some(commit_email)) => {
Entry::change_name_and_email_by_name_and_email(proper_name, proper_email, commit_name, commit_email)
}
_ => {
return Err(Error::Malformed {
line_number,
line: line.into(),
message: "Emails without a name or email to map to are invalid".into(),
})
}
})
}sourcepub fn change_email_by_email(
proper_email: impl Into<&'a BStr>,
commit_email: impl Into<&'a BStr>
) -> Self
pub fn change_email_by_email(
proper_email: impl Into<&'a BStr>,
commit_email: impl Into<&'a BStr>
) -> Self
Examples found in repository?
src/parse.rs (line 73)
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
fn parse_line(line: &BStr, line_number: usize) -> Result<Entry<'_>, Error> {
let (name1, email1, rest) = parse_name_and_email(line, line_number)?;
let (name2, email2, rest) = parse_name_and_email(rest, line_number)?;
if !rest.trim().is_empty() {
return Err(Error::UnconsumedInput {
line_number,
line: line.into(),
});
}
Ok(match (name1, email1, name2, email2) {
(Some(proper_name), Some(commit_email), None, None) => Entry::change_name_by_email(proper_name, commit_email),
(None, Some(proper_email), None, Some(commit_email)) => {
Entry::change_email_by_email(proper_email, commit_email)
}
(Some(proper_name), Some(proper_email), None, Some(commit_email)) => {
Entry::change_name_and_email_by_email(proper_name, proper_email, commit_email)
}
(Some(proper_name), Some(proper_email), Some(commit_name), Some(commit_email)) => {
Entry::change_name_and_email_by_name_and_email(proper_name, proper_email, commit_name, commit_email)
}
_ => {
return Err(Error::Malformed {
line_number,
line: line.into(),
message: "Emails without a name or email to map to are invalid".into(),
})
}
})
}sourcepub fn change_name_and_email_by_email(
proper_name: impl Into<&'a BStr>,
proper_email: impl Into<&'a BStr>,
commit_email: impl Into<&'a BStr>
) -> Self
pub fn change_name_and_email_by_email(
proper_name: impl Into<&'a BStr>,
proper_email: impl Into<&'a BStr>,
commit_email: impl Into<&'a BStr>
) -> Self
Examples found in repository?
src/parse.rs (line 76)
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
fn parse_line(line: &BStr, line_number: usize) -> Result<Entry<'_>, Error> {
let (name1, email1, rest) = parse_name_and_email(line, line_number)?;
let (name2, email2, rest) = parse_name_and_email(rest, line_number)?;
if !rest.trim().is_empty() {
return Err(Error::UnconsumedInput {
line_number,
line: line.into(),
});
}
Ok(match (name1, email1, name2, email2) {
(Some(proper_name), Some(commit_email), None, None) => Entry::change_name_by_email(proper_name, commit_email),
(None, Some(proper_email), None, Some(commit_email)) => {
Entry::change_email_by_email(proper_email, commit_email)
}
(Some(proper_name), Some(proper_email), None, Some(commit_email)) => {
Entry::change_name_and_email_by_email(proper_name, proper_email, commit_email)
}
(Some(proper_name), Some(proper_email), Some(commit_name), Some(commit_email)) => {
Entry::change_name_and_email_by_name_and_email(proper_name, proper_email, commit_name, commit_email)
}
_ => {
return Err(Error::Malformed {
line_number,
line: line.into(),
message: "Emails without a name or email to map to are invalid".into(),
})
}
})
}sourcepub fn change_name_and_email_by_name_and_email(
proper_name: impl Into<&'a BStr>,
proper_email: impl Into<&'a BStr>,
commit_name: impl Into<&'a BStr>,
commit_email: impl Into<&'a BStr>
) -> Self
pub fn change_name_and_email_by_name_and_email(
proper_name: impl Into<&'a BStr>,
proper_email: impl Into<&'a BStr>,
commit_name: impl Into<&'a BStr>,
commit_email: impl Into<&'a BStr>
) -> Self
Examples found in repository?
src/parse.rs (line 79)
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
fn parse_line(line: &BStr, line_number: usize) -> Result<Entry<'_>, Error> {
let (name1, email1, rest) = parse_name_and_email(line, line_number)?;
let (name2, email2, rest) = parse_name_and_email(rest, line_number)?;
if !rest.trim().is_empty() {
return Err(Error::UnconsumedInput {
line_number,
line: line.into(),
});
}
Ok(match (name1, email1, name2, email2) {
(Some(proper_name), Some(commit_email), None, None) => Entry::change_name_by_email(proper_name, commit_email),
(None, Some(proper_email), None, Some(commit_email)) => {
Entry::change_email_by_email(proper_email, commit_email)
}
(Some(proper_name), Some(proper_email), None, Some(commit_email)) => {
Entry::change_name_and_email_by_email(proper_name, proper_email, commit_email)
}
(Some(proper_name), Some(proper_email), Some(commit_name), Some(commit_email)) => {
Entry::change_name_and_email_by_name_and_email(proper_name, proper_email, commit_name, commit_email)
}
_ => {
return Err(Error::Malformed {
line_number,
line: line.into(),
message: "Emails without a name or email to map to are invalid".into(),
})
}
})
}Trait Implementations§
source§impl<'de: 'a, 'a> Deserialize<'de> for Entry<'a>
impl<'de: 'a, 'a> Deserialize<'de> for Entry<'a>
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<'a> Ord for Entry<'a>
impl<'a> Ord for Entry<'a>
source§impl<'a> PartialEq<Entry<'a>> for Entry<'a>
impl<'a> PartialEq<Entry<'a>> for Entry<'a>
source§impl<'a> PartialOrd<Entry<'a>> for Entry<'a>
impl<'a> PartialOrd<Entry<'a>> for Entry<'a>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read more