Answer the question
In order to leave comments, you need to log in
Is memory allocated when creating &str?
I have an array of bytes and I want to convert the first 10 bytes to a string.
if i do String::from_utf8_lossy() it will return &str.
Do I understand correctly that &str is the address of those 10 bytes and in fact the memory will be allocated only when the link is created? Thank you!
Answer the question
In order to leave comments, you need to log in
There is some misunderstanding here. Memory allocation usually means its allocation in dynamic memory , while variables and arguments live in stack memory .
And now, answering your question:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question