Browse Source

move EnumValueTools.match (#7416)

Guillaume Desquesnes 7 years ago
parent
commit
205c815fb2
2 changed files with 31 additions and 30 deletions
  1. 31 0
      std/EnumValue.hx
  2. 0 30
      std/haxe/EnumTools.hx

+ 31 - 0
std/EnumValue.hx

@@ -27,4 +27,35 @@
 	@see https://haxe.org/manual/types-enum-instance.html
 **/
 @:coreType abstract EnumValue {
+	/**
+		Matches enum instance `e` against pattern `pattern`, returning `true` if
+		matching succeeded and `false` otherwise.
+
+		Example usage:
+
+		```haxe
+		if (e.match(pattern)) {
+			// codeIfTrue
+		} else {
+			// codeIfFalse
+		}
+		```
+
+		This is equivalent to the following code:
+
+		```haxe
+		switch (e) {
+			case pattern:
+				// codeIfTrue
+			case _:
+				// codeIfFalse
+		}
+		```
+
+		This method is implemented in the compiler. This definition exists only
+		for documentation.
+	**/
+	public function match(pattern:Dynamic):Bool {
+		return false;
+	}
 }

+ 0 - 30
std/haxe/EnumTools.hx

@@ -169,34 +169,4 @@ extern class EnumValueTools {
 	static public inline function getIndex(e:EnumValue):Int {
 		return Type.enumIndex(e);
 	}
-
-	/**
-		Matches enum instance `e` against pattern `pattern`, returning `true` if
-		matching succeeded and `false` otherwise.
-
-		Example usage:
-
-		```haxe
-		if (e.match(pattern)) {
-			// codeIfTrue
-		} else {
-			// codeIfFalse
-		}
-		```
-
-		This is equivalent to the following code:
-
-		```haxe
-		switch (e) {
-			case pattern:
-				// codeIfTrue
-			case _:
-				// codeIfFalse
-		}
-		```
-
-		This method is implemented in the compiler. This definition exists only
-		for documentation.
-	**/
-	static public function match(e:EnumValue, pattern:Dynamic):Bool;
 }