@@ -318,15 +318,13 @@ mod sealed {
318
318
319
319
impl <T : $feature> Features <T > {
320
320
/// Set this feature as optional.
321
- pub fn $optional_setter( mut self ) -> Self {
321
+ pub fn $optional_setter( & mut self ) {
322
322
<T as $feature>:: set_optional_bit( & mut self . flags) ;
323
- self
324
323
}
325
324
326
325
/// Set this feature as required.
327
- pub fn $required_setter( mut self ) -> Self {
326
+ pub fn $required_setter( & mut self ) {
328
327
<T as $feature>:: set_required_bit( & mut self . flags) ;
329
- self
330
328
}
331
329
332
330
/// Checks if this feature is supported.
@@ -506,7 +504,9 @@ impl InvoiceFeatures {
506
504
/// [`PaymentParameters::for_keysend`]: crate::routing::router::PaymentParameters::for_keysend
507
505
/// [`find_route`]: crate::routing::router::find_route
508
506
pub ( crate ) fn for_keysend ( ) -> InvoiceFeatures {
509
- InvoiceFeatures :: empty ( ) . set_variable_length_onion_optional ( )
507
+ let mut res = InvoiceFeatures :: empty ( ) ;
508
+ res. set_variable_length_onion_optional ( ) ;
509
+ res
510
510
}
511
511
}
512
512
@@ -838,11 +838,13 @@ mod tests {
838
838
assert ! ( !features. requires_unknown_bits( ) ) ;
839
839
assert ! ( !features. supports_unknown_bits( ) ) ;
840
840
841
- let features = ChannelFeatures :: empty ( ) . set_unknown_feature_required ( ) ;
841
+ let mut features = ChannelFeatures :: empty ( ) ;
842
+ features. set_unknown_feature_required ( ) ;
842
843
assert ! ( features. requires_unknown_bits( ) ) ;
843
844
assert ! ( features. supports_unknown_bits( ) ) ;
844
845
845
- let features = ChannelFeatures :: empty ( ) . set_unknown_feature_optional ( ) ;
846
+ let mut features = ChannelFeatures :: empty ( ) ;
847
+ features. set_unknown_feature_optional ( ) ;
846
848
assert ! ( !features. requires_unknown_bits( ) ) ;
847
849
assert ! ( features. supports_unknown_bits( ) ) ;
848
850
}
@@ -886,17 +888,18 @@ mod tests {
886
888
fn convert_to_context_with_unknown_flags ( ) {
887
889
// Ensure the `from` context has fewer known feature bytes than the `to` context.
888
890
assert ! ( InvoiceFeatures :: known( ) . flags. len( ) < NodeFeatures :: known( ) . flags. len( ) ) ;
889
- let invoice_features = InvoiceFeatures :: known ( ) . set_unknown_feature_optional ( ) ;
891
+ let mut invoice_features = InvoiceFeatures :: known ( ) ;
892
+ invoice_features. set_unknown_feature_optional ( ) ;
890
893
assert ! ( invoice_features. supports_unknown_bits( ) ) ;
891
894
let node_features: NodeFeatures = invoice_features. to_context ( ) ;
892
895
assert ! ( !node_features. supports_unknown_bits( ) ) ;
893
896
}
894
897
895
898
#[ test]
896
899
fn set_feature_bits ( ) {
897
- let features = InvoiceFeatures :: empty ( )
898
- . set_basic_mpp_optional ( )
899
- . set_payment_secret_required ( ) ;
900
+ let mut features = InvoiceFeatures :: empty ( ) ;
901
+ features . set_basic_mpp_optional ( ) ;
902
+ features . set_payment_secret_required ( ) ;
900
903
assert ! ( features. supports_basic_mpp( ) ) ;
901
904
assert ! ( !features. requires_basic_mpp( ) ) ;
902
905
assert ! ( features. requires_payment_secret( ) ) ;
@@ -938,7 +941,8 @@ mod tests {
938
941
fn test_channel_type_mapping ( ) {
939
942
// If we map an InvoiceFeatures with StaticRemoteKey optional, it should map into a
940
943
// required-StaticRemoteKey ChannelTypeFeatures.
941
- let init_features = InitFeatures :: empty ( ) . set_static_remote_key_optional ( ) ;
944
+ let mut init_features = InitFeatures :: empty ( ) ;
945
+ init_features. set_static_remote_key_optional ( ) ;
942
946
let converted_features = ChannelTypeFeatures :: from_counterparty_init ( & init_features) ;
943
947
assert_eq ! ( converted_features, ChannelTypeFeatures :: only_static_remote_key( ) ) ;
944
948
assert ! ( !converted_features. supports_any_optional_bits( ) ) ;
0 commit comments