Skip to content

Commit d545dfe

Browse files
committed
feat(strs_tools): Manually implement SplitOptionsFormer setters and form method
1 parent cf4f8b1 commit d545dfe

File tree

1 file changed

+43
-8
lines changed
  • module/core/strs_tools/src/string

1 file changed

+43
-8
lines changed

module/core/strs_tools/src/string/split.rs

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -443,13 +443,13 @@ mod private
443443
quoting_prefixes : Vec< &'a str >,
444444
quoting_postfixes : Vec< &'a str >,
445445
}
446-
builder_impls_from!
447-
(
448-
SplitOptionsFormer,
449-
( preserving_empty, bool ), ( preserving_delimeters, bool ), ( preserving_quoting, bool ),
450-
( stripping, bool ), ( quoting, bool ),
451-
( quoting_prefixes, Vec< &'a str > ), ( quoting_postfixes, Vec< &'a str > ),
452-
);
446+
// builder_impls_from!
447+
// (
448+
// SplitOptionsFormer,
449+
// ( preserving_empty, bool ), ( preserving_delimeters, bool ), ( preserving_quoting, bool ),
450+
// ( stripping, bool ), ( quoting, bool ),
451+
// ( quoting_prefixes, Vec< &'a str > ), ( quoting_postfixes, Vec< &'a str > ),
452+
// );
453453

454454
impl< 'a > SplitOptionsFormer< 'a >
455455
{
@@ -465,9 +465,44 @@ mod private
465465
quoting_prefixes : vec![], quoting_postfixes : vec![],
466466
}
467467
}
468+
469+
// Manually added setters
470+
pub fn preserving_empty( &mut self, value : bool ) -> &mut Self { self.preserving_empty = value; self }
471+
pub fn preserving_delimeters( &mut self, value : bool ) -> &mut Self { self.preserving_delimeters = value; self }
472+
pub fn preserving_quoting( &mut self, value : bool ) -> &mut Self { self.preserving_quoting = value; self }
473+
pub fn stripping( &mut self, value : bool ) -> &mut Self { self.stripping = value; self }
474+
pub fn quoting( &mut self, value : bool ) -> &mut Self { self.quoting = value; self }
475+
pub fn quoting_prefixes( &mut self, value : Vec< &'a str > ) -> &mut Self { self.quoting_prefixes = value; self }
476+
pub fn quoting_postfixes( &mut self, value : Vec< &'a str > ) -> &mut Self { self.quoting_postfixes = value; self }
477+
478+
// Existing methods that were likely part of the manual impl before, or should be retained
479+
pub fn src( &mut self, value : &'a str ) -> &mut Self { self.src = value; self }
468480
pub fn delimeter< D : Into< OpType< &'a str > > >( &mut self, value : D ) -> &mut Self
469481
{ self.delimeter = OpType::Vector( vec![] ).append( value.into() ); self }
470-
pub fn src( &mut self, value : &'a str ) -> &mut Self { self.src = value; self }
482+
483+
// Manually added form method
484+
pub fn form( &mut self ) -> SplitOptions< 'a, Vec< &'a str > >
485+
{
486+
if self.quoting
487+
{
488+
if self.quoting_prefixes.is_empty() { self.quoting_prefixes = vec![ "\"", "`", "'" ]; }
489+
if self.quoting_postfixes.is_empty() { self.quoting_postfixes = vec![ "\"", "`", "'" ]; }
490+
}
491+
SplitOptions
492+
{
493+
src : self.src,
494+
delimeter : self.delimeter.clone().vector().unwrap(),
495+
preserving_empty : self.preserving_empty,
496+
preserving_delimeters : self.preserving_delimeters,
497+
preserving_quoting : self.preserving_quoting,
498+
stripping : self.stripping,
499+
quoting : self.quoting,
500+
quoting_prefixes : self.quoting_prefixes.clone(),
501+
quoting_postfixes : self.quoting_postfixes.clone(),
502+
}
503+
}
504+
505+
// Existing perform method
471506
pub fn perform( &mut self ) -> SplitIterator< 'a > { self.form().split() }
472507
}
473508

0 commit comments

Comments
 (0)