Browse Source

Adds implicit Span<char8> operator to String

xposure 4 năm trước cách đây
mục cha
commit
aeb0e70d21
1 tập tin đã thay đổi với 7 bổ sung0 xóa
  1. 7 0
      BeefLibs/corlib/src/String.bf

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

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