Răsfoiți Sursa

Merge pull request #785 from xposure/master

DeleteDictionaryAndItems + String to span<char8>
Brian Fiete 4 ani în urmă
părinte
comite
d78cb3182a
2 a modificat fișierele cu 19 adăugiri și 0 ștergeri
  1. 7 0
      BeefLibs/corlib/src/String.bf
  2. 12 0
      BeefLibs/corlib/src/System.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)
 		{

+ 12 - 0
BeefLibs/corlib/src/System.bf

@@ -187,6 +187,18 @@ static
 		}
 	}
 
+	public static mixin DeleteDictionaryAndItems(var container)
+	{
+		if (container != null)
+		{
+			for (var value in container)
+			{
+				delete value.value;
+			}
+			delete container;
+		}
+	}
+
 	public static mixin DeleteDictionaryAndKeysAndItems(var container)
 	{
 		if (container != null)