浏览代码

Adds implicit Span<char8> operator to String

xposure 4 年之前
父节点
当前提交
aeb0e70d21
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      BeefLibs/corlib/src/String.bf

+ 7 - 0
BeefLibs/corlib/src/String.bf

@@ -551,6 +551,13 @@ namespace System
 			return str.Ptr;
 		}
 
+		public static implicit operator Span<char8>(String str)
+		{
+		    if (str == null)
+				return .(null, 0);
+			return .(str.Ptr, str.Length);
+		}
+
 		[Commutable]
 		public static bool operator==(String s1, String s2)
 		{