Analogue function Println! in run time

Problem: I had used func stdin() and further want to write in file this symbol, compile complain to write() func)

Can you provide some sample code that either demonstrates what you want to do or produces the error you’re having trouble with?

Now i had done the same, but no problems, however he wrote that this cannot be known at compile time)
But another questions if you maybe know and can help me,1I have a vector, needed to print them one by one,also as named arguments
2 I need to return Vec<&str>in func, but rust request additional life time, what i need to do?)
And also question, all that rust do is in compile time?) Can you take an analogue from c++, thanks)

To answer this properly, it's important for us to see the broken code you have right now and a copy of the compiler output: There are several potential problems (and associated fixes) that you might have, and there's not enough detail here to tell the difference between them.


Raw 163:why it is mistake, but 164 not
Vector init 150, want to exact data one by one
Maybe want return vector<&str>, he wrote needed lifetime

I know difference, but i can't return vector<&str>,only vector, that what i want to know, what should i wrote about lifetime in func)

str::to_string turns &str into String, so you must collect it into Vec<String> not Vec<&str>.

1 Like

Similar to this i had done(it' easy),i want to know why.Also if i return vec<&str> what lifetime i need to write.
Also i had asked, how i can write elements one by one, in 181-188 raws)

The lifetime of the input reference, of course. There's no other lifetime here anyway (well, there's 'static, but it means that the string is either the literal or explicitly leaked).