Hi Ashish,

Yes that works fine. Splitting out 'args' into a separate variable fixes
the behaviour.
So this is a lifetime issue and the latest compiler isn't picking it up?

Thanks,

Phil


On Wed, Feb 26, 2014 at 4:23 AM, Ashish Myles <[email protected]> wrote:

> On Tue, Feb 25, 2014 at 11:00 AM, Phil Dawes <[email protected]>wrote:
>
>> fn main() {
>>     let arr : ~[&str] = std::os::args()[1].split_str("::").collect();
>>     std::io::println("first " + arr[0]);
>>     std::io::println("first again " + arr[0]);
>> }
>>
>
> I am working on an older version of the compiler that fails to compile
> this code, giving an error about the reference to the return value of
> std::os::args() not being valid for the duration of its use.
> Does
>     let args = std::os::args();
>     let arr : ~[&str] = args[1].split_str("::").collect();
> work properly?
>
> Ashish
>
>
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to