Skip to content

Commit 5017061

Browse files
committed
fix: use explicit lifetimes at new functions
1 parent d76f543 commit 5017061

File tree

10 files changed

+20
-29
lines changed

10 files changed

+20
-29
lines changed

src/address.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub struct Address<'a> {
1313
}
1414

1515
impl<'a> Address<'a> {
16-
pub fn new(name: &'a str, town: &'a str, zip: &'a str, country: &'a str) -> Address<'a> {
16+
pub fn new(name: &'a str, town: &'a str, zip: &'a str, country: &'a str) -> Self {
1717
Address {
1818
name,
1919
town,

src/biller.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub struct Biller<'a> {
1616
}
1717

1818
impl<'a> Biller<'a> {
19-
pub fn new(vat_identification_number: &str) -> Biller {
19+
pub fn new(vat_identification_number: &'a str) -> Self {
2020
Biller {
2121
vat_identification_number,
2222
..Default::default()

src/contact.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub struct Contact<'a> {
99
}
1010

1111
impl<'a> Contact<'a> {
12-
pub fn new(name: &str) -> Contact {
12+
pub fn new(name: &'a str) -> Self {
1313
Contact {
1414
name,
1515
..Default::default()

src/details.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,7 @@ pub struct DetailsItem<'a> {
2222
}
2323

2424
impl<'a> DetailsItem<'a> {
25-
pub fn new(
26-
quantity: Decimal,
27-
unit: &'a str,
28-
unit_price: Decimal,
29-
tax_item: TaxItem,
30-
) -> DetailsItem<'a> {
25+
pub fn new(quantity: Decimal, unit: &'a str, unit_price: Decimal, tax_item: TaxItem) -> Self {
3126
DetailsItem {
3227
quantity,
3328
unit,

src/identification.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ pub struct FurtherIdentification<'a> {
4848
id_type: FurtherIdentificationType,
4949
}
5050

51-
impl FurtherIdentification<'_> {
52-
pub fn new(id: &str, id_type: FurtherIdentificationType) -> FurtherIdentification {
51+
impl<'a> FurtherIdentification<'a> {
52+
pub fn new(id: &'a str, id_type: FurtherIdentificationType) -> Self {
5353
FurtherIdentification { id, id_type }
5454
}
5555
}

src/invoice_recipient.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub struct InvoiceRecipient<'a> {
1616
}
1717

1818
impl<'a> InvoiceRecipient<'a> {
19-
pub fn new(vat_identification_number: &str) -> InvoiceRecipient {
19+
pub fn new(vat_identification_number: &'a str) -> Self {
2020
InvoiceRecipient {
2121
vat_identification_number,
2222
..Default::default()

src/order_reference.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub struct OrderReference<'a> {
88
}
99

1010
impl<'a> OrderReference<'a> {
11-
pub fn new(order_id: &str) -> OrderReference {
11+
pub fn new(order_id: &'a str) -> Self {
1212
OrderReference {
1313
order_id,
1414
..Default::default()

src/payment_method.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ trait MatchBicRegex {
5353
impl MatchBicRegex for PaymentMethodSEPADirectDebit<'_> {}
5454

5555
impl<'a> PaymentMethodSEPADirectDebit<'a> {
56-
pub fn new() -> PaymentMethodSEPADirectDebit<'a> {
56+
pub fn new() -> Self {
5757
PaymentMethodSEPADirectDebit {
5858
..Default::default()
5959
}
@@ -163,10 +163,7 @@ pub struct PaymentMethodUniversalBankTransactionBeneficiaryAccountBankCode<'a> {
163163
}
164164

165165
impl<'a> PaymentMethodUniversalBankTransactionBeneficiaryAccountBankCode<'a> {
166-
pub fn new(
167-
bank_code: i64,
168-
bank_code_type: &'a str,
169-
) -> PaymentMethodUniversalBankTransactionBeneficiaryAccountBankCode<'a> {
166+
pub fn new(bank_code: i64, bank_code_type: &'a str) -> Self {
170167
PaymentMethodUniversalBankTransactionBeneficiaryAccountBankCode {
171168
bank_code,
172169
bank_code_type,
@@ -187,7 +184,7 @@ pub struct PaymentMethodUniversalBankTransactionBeneficiaryAccount<'a> {
187184
impl MatchBicRegex for PaymentMethodUniversalBankTransactionBeneficiaryAccount<'_> {}
188185

189186
impl<'a> PaymentMethodUniversalBankTransactionBeneficiaryAccount<'a> {
190-
pub fn new() -> PaymentMethodUniversalBankTransactionBeneficiaryAccount<'a> {
187+
pub fn new() -> Self {
191188
PaymentMethodUniversalBankTransactionBeneficiaryAccount {
192189
..Default::default()
193190
}
@@ -292,7 +289,7 @@ pub struct PaymentMethodUniversalBankTransaction<'a> {
292289
}
293290

294291
impl<'a> PaymentMethodUniversalBankTransaction<'a> {
295-
pub fn new() -> PaymentMethodUniversalBankTransaction<'a> {
292+
pub fn new() -> Self {
296293
PaymentMethodUniversalBankTransaction {
297294
..Default::default()
298295
}
@@ -366,7 +363,7 @@ pub struct PaymentMethodPaymentCard<'a> {
366363
}
367364

368365
impl<'a> PaymentMethodPaymentCard<'a> {
369-
pub fn new(primary_account_number: &'a str) -> Result<PaymentMethodPaymentCard<'a>, String> {
366+
pub fn new(primary_account_number: &'a str) -> Result<Self, String> {
370367
static PAYMENT_CARD_REGEX_STR: &str = r"^[0-9]{0,6}\*[0-9]{0,4}$";
371368
static PAYMENT_CARD_REGEX: LazyLock<Regex> =
372369
LazyLock::new(|| Regex::new(PAYMENT_CARD_REGEX_STR).unwrap());

src/reduction_and_surcharge.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ struct ReductionAndSurchargeListLineItemBase<'a> {
1818
}
1919

2020
impl<'a> ReductionAndSurchargeListLineItemBase<'a> {
21-
fn new(
22-
base_amount: Decimal,
23-
value: ReductionAndSurchargeValue,
24-
) -> ReductionAndSurchargeListLineItemBase<'a> {
21+
fn new(base_amount: Decimal, value: ReductionAndSurchargeValue) -> Self {
2522
ReductionAndSurchargeListLineItemBase {
2623
base_amount,
2724
value,
@@ -42,8 +39,10 @@ impl<'a> ReductionAndSurchargeListLineItemBase<'a> {
4239
}
4340

4441
fn to_xml_elements(&self) -> Vec<XmlElement> {
45-
let mut es = vec![XmlElement::new("BaseAmount")
46-
.with_text(self.base_amount.clone_with_scale(2).to_string())];
42+
let mut es = vec![
43+
XmlElement::new("BaseAmount")
44+
.with_text(self.base_amount.clone_with_scale(2).to_string()),
45+
];
4746

4847
match self.value {
4948
ReductionAndSurchargeValue::Percentage(percentage) => {
@@ -149,7 +148,7 @@ pub struct ReductionAndSurchargeListLineItemDetails<'a> {
149148
}
150149

151150
impl<'a> ReductionAndSurchargeListLineItemDetails<'a> {
152-
pub fn new() -> ReductionAndSurchargeListLineItemDetails<'a> {
151+
pub fn new() -> Self {
153152
ReductionAndSurchargeListLineItemDetails {
154153
..Default::default()
155154
}

src/tax.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub struct TaxItem {
5252
}
5353

5454
impl TaxItem {
55-
pub fn new(tax_percent: Decimal, tax_category: TaxCategory) -> TaxItem {
55+
pub fn new(tax_percent: Decimal, tax_category: TaxCategory) -> Self {
5656
TaxItem {
5757
tax_percent,
5858
tax_category,

0 commit comments

Comments
 (0)