Panic with message if empty data buffer

This commit is contained in:
Gabriel Majeri 2017-06-16 18:53:53 +03:00
parent 9229acb069
commit 1768891c33

View File

@ -124,12 +124,16 @@ impl<T> CpuAccessibleBuffer<T> {
impl<T> CpuAccessibleBuffer<[T]> {
/// Builds a new buffer that contains an array `T`. The initial data comes from an iterator
/// that produces that list of Ts.
/// # Panics
/// Panics if the initial data is empty.
pub fn from_iter<'a, I, Q>(device: Arc<Device>, usage: BufferUsage, queue_families: Q, data: I)
-> Result<Arc<CpuAccessibleBuffer<[T]>>, OomError>
where I: ExactSizeIterator<Item = T>,
T: Content + 'static,
Q: IntoIterator<Item = QueueFamily<'a>>
{
assert_neq!(data.len(), 0, "Tried to create buffer from empty iterator.");
unsafe {
let uninitialized = try!(
CpuAccessibleBuffer::uninitialized_array(device, data.len(), usage, queue_families)