core icon indicating copy to clipboard operation
core copied to clipboard

[BUG] queue transfer to self should be no-op

Open quake opened this issue 6 months ago • 5 comments

Describe the bug queue transfer to self should be no-op

To Reproduce

fn main {
    let q = @queue.of([1, 2, 3])
    q.transfer(q)
    println(q)
}

ouputs @queue.of([])

Expected behavior @queue.of([1, 2, 3])

quake avatar Aug 28 '25 14:08 quake

/// Transfers all elements from one queue to another.
///
/// Adds all of the elements of source to the end of destination, then clears source.

peter-jerry-ye avatar Aug 29 '25 05:08 peter-jerry-ye

This is not intuitive. The implementation detail should not lead API design

hackwaly avatar Aug 29 '25 09:08 hackwaly

It is what it is. Transferring to self doesn't make sense either. With that said, with the append implemented, I would rather deprecate this API.

peter-jerry-ye avatar Aug 29 '25 10:08 peter-jerry-ye

However, append will not imply the empty operation on source.

hackwaly avatar Sep 01 '25 05:09 hackwaly

Yes, and it is exactly this empty operation is bizarre when the source and dst refers to the same one

peter-jerry-ye avatar Sep 01 '25 09:09 peter-jerry-ye