File tree Expand file tree Collapse file tree 3 files changed +32
-9
lines changed Expand file tree Collapse file tree 3 files changed +32
-9
lines changed Original file line number Diff line number Diff line change @@ -102,10 +102,13 @@ fn main() {
102102 let stderr = io:: stderr ( ) ;
103103 let mut stderr = stderr. lock ( ) ;
104104
105- let options = DemangleOptions {
106- no_params : matches. is_present ( "noparams" ) ,
107- no_return_type : matches. is_present ( "noreturntype" ) ,
108- } ;
105+ let mut options = DemangleOptions :: new ( ) ;
106+ if matches. is_present ( "noparams" ) {
107+ options = options. no_params ( ) ;
108+ }
109+ if matches. is_present ( "noreturntype" ) {
110+ options = options. no_return_type ( ) ;
111+ }
109112
110113 let demangle_result = if let Some ( names) = matches. values_of ( "mangled_names" ) {
111114 let mut input = Cursor :: new ( names. fold ( String :: new ( ) , |mut accumulated, name| {
Original file line number Diff line number Diff line change @@ -86,10 +86,27 @@ use std::fmt;
8686/// Options to control the demangling process.
8787#[ derive( Clone , Copy , Debug , Default ) ]
8888pub struct DemangleOptions {
89+ no_params : bool ,
90+ no_return_type : bool ,
91+ }
92+
93+ impl DemangleOptions {
94+ /// Construct a new `DemangleOptions` with the default values.
95+ pub fn new ( ) -> Self {
96+ Default :: default ( )
97+ }
98+
8999 /// Do not display function arguments.
90- pub no_params : bool ,
100+ pub fn no_params ( mut self ) -> Self {
101+ self . no_params = true ;
102+ self
103+ }
104+
91105 /// Do not display the function return type.
92- pub no_return_type : bool ,
106+ pub fn no_return_type ( mut self ) -> Self {
107+ self . no_return_type = true ;
108+ self
109+ }
93110}
94111
95112/// A `Symbol` which owns the underlying storage for the mangled name.
@@ -251,6 +268,9 @@ pub enum DemangleNodeType {
251268 NestedName ,
252269 /// Entering a <special-name> production that is a vtable.
253270 VirtualTable ,
271+ /// Additional values may be added in the future. Use a
272+ /// _ pattern for compatibility.
273+ __NonExhaustive,
254274}
255275
256276/// Sink for demangled text that reports syntactic structure.
Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ macro_rules! demangles_no_param_and_no_return_type {
8787 ( $name: ident , $mangled: expr , $demangled: expr ) => {
8888 #[ test]
8989 fn $name( ) {
90- let options = DemangleOptions { no_params : true , no_return_type : true } ;
90+ let options = DemangleOptions :: new ( ) . no_params ( ) . no_return_type ( ) ;
9191 assert_demangles_as( $mangled, $demangled, Some ( options) ) ;
9292 }
9393 } ;
@@ -100,7 +100,7 @@ macro_rules! demangles_no_return_type {
100100 ( $name: ident , $mangled: expr , $demangled: expr ) => {
101101 #[ test]
102102 fn $name( ) {
103- let options = DemangleOptions { no_params : false , no_return_type : true } ;
103+ let options = DemangleOptions :: new ( ) . no_return_type ( ) ;
104104 assert_demangles_as( $mangled, $demangled, Some ( options) ) ;
105105 }
106106 } ;
@@ -113,7 +113,7 @@ macro_rules! demangles_no_param {
113113 ( $name: ident , $mangled: expr , $demangled: expr ) => {
114114 #[ test]
115115 fn $name( ) {
116- let options = DemangleOptions { no_params : true , no_return_type : false } ;
116+ let options = DemangleOptions :: new ( ) . no_params ( ) ;
117117 assert_demangles_as( $mangled, $demangled, Some ( options) ) ;
118118 }
119119 } ;
You can’t perform that action at this time.
0 commit comments