boxcar icon indicating copy to clipboard operation
boxcar copied to clipboard

feature request push_get()

Open nevakrien opened this issue 2 months ago • 1 comments

so i am making an arena allocator for something and boxcar has been a life saver. runing

pub fn alloc(&self,s:String)->&str{
		self.vec.get(self.0.push(s)).unwrap()
	}

does wonders its like SO simple and it works great. problem is it makes for a bad binary even on release. the fact we have to call get again after the push is costing a lot.

if we had a push_get method which would return not only the id but also a reference that would be amazing.

nevakrien avatar Oct 22 '25 15:10 nevakrien

I agree this should be possible. Perhaps it makes sense to change the signature of push_with to return &T (or maybe (usize, &T)), as the index is already available from within the closure, instead of adding a new method.

ibraheemdev avatar Oct 22 '25 21:10 ibraheemdev