We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4a6e310 commit 9dbb833Copy full SHA for 9dbb833
string/view.mbt
@@ -447,3 +447,9 @@ pub fn StringView::iter(self : StringView) -> Iter[Char] {
447
}
448
})
449
450
+
451
+///|
452
+/// Returns true if the view is empty.
453
+pub fn StringView::is_empty(self : StringView) -> Bool {
454
+ self.start == self.end
455
+}
string/view_test.mbt
@@ -514,3 +514,14 @@ test "panic stringview negative index3" {
514
let _ = str[-1:-2]
515
516
517
518
+test "is_empty" {
519
+ let str = "hello"
520
+ let view = str[1:4]
521
+ inspect!(view.is_empty(), content="false")
522
+ let view = str[0:0]
523
+ inspect!(view.is_empty(), content="true")
524
+ let str = ""
525
+ let view = str[:]
526
527
0 commit comments