File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -928,13 +928,26 @@ impl RequiredExtensionStrategyBuilder {
928928///
929929/// The escaping works by surrounding meta-characters with brackets. For
930930/// example, `*` becomes `[*]`.
931+ ///
932+ /// # Example
933+ ///
934+ /// ```
935+ /// use globset::escape;
936+ ///
937+ /// assert_eq!(escape("foo*bar"), "foo[*]bar");
938+ /// assert_eq!(escape("foo?bar"), "foo[?]bar");
939+ /// assert_eq!(escape("foo[bar"), "foo[[]bar");
940+ /// assert_eq!(escape("foo]bar"), "foo[]]bar");
941+ /// assert_eq!(escape("foo{bar"), "foo[{]bar");
942+ /// assert_eq!(escape("foo}bar"), "foo[}]bar");
943+ /// ```
931944pub fn escape ( s : & str ) -> String {
932945 let mut escaped = String :: with_capacity ( s. len ( ) ) ;
933946 for c in s. chars ( ) {
934947 match c {
935948 // note that ! does not need escaping because it is only special
936949 // inside brackets
937- '?' | '*' | '[' | ']' => {
950+ '?' | '*' | '[' | ']' | '{' | '}' => {
938951 escaped. push ( '[' ) ;
939952 escaped. push ( c) ;
940953 escaped. push ( ']' ) ;
You can’t perform that action at this time.
0 commit comments