About the help category

Requests for help.

Post requests for help here.

2 Likes

I just tried to install Rust on my windows-10 machine. I installed "Microsoft C++ build tools for Visual Studio" as suggested, but on retrying the install it didn't seem to work ( it still asked for them to be installed, I continued anyway, but then later on cargo created a directory, but then failed, I think with message about link.exe not being found ).

I can get this prompt up, so I think I did install the tools, but it seems it's not finding them?


** Visual Studio 2019 Developer Command Prompt v16.6.3
** Copyright (c) 2020 Microsoft Corporation


C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools>

Any idea what I can do to get it to work?

[ I did previous do a 30-day trial of Visual Studio, that is still installed but not runnable as the 30-day period expired, could that be causing a problem perhaps? I tried uninstalling it, didn't seem to help. ]

Edit: This is the error screen I get:

C:\Users\pc\hello-rust>cargo run
Compiling hello-rust v0.1.0 (C:\Users\pc\hello-rust)
error: linker link.exe not found
|
= note: The system cannot find the file specified. (os error 2)

note: the msvc targets depend on the msvc linker but link.exe was not found

note: please ensure that VS 2013, VS 2015, VS 2017 or VS 2019 was installed with the Visual C++ option

error: aborting due to previous error

error: could not compile hello-rust.

To learn more, run the command again with --verbose.

C:\Users\pc\hello-rust>

UPDATE:

I uninstalled ""Microsoft C++ build tools for Visual Studio" etc. completely, re-installed, and now everything is working ok.

1 Like

That's not what this thread is for xD

You're meant to post a new thread under the help category :stuck_out_tongue:

4 Likes

Parsing type SystemTime.

I am currently using Rust in Linux to examine nearly a billion files. One of the things I need is the file modified date/time in a particular format, which can be conveniently be obtained using Crate chrono. I therefore extract a file's Metadata from its directory entry. While in practice error handling is very important (so the routine never crashes out and abandons hours of successful results), for the purposes of this question I will by-pass all that by using .unwrap() for clarity. so I have:

let file_metadata=fs::metadata(file_path).unwrap();
let file_last_modified=file_metadata.modified().unwrap();

If I now look at the format of this:

print!("{:?} : ",file_last_modified);

I get, for example:- 'SystemTime { tv_sec: 1594033168, tv_nsec: 848710897 }' which I feel I need to somehow feed into crate chrono. I am aware of:-

let file_datestamp=Utc.timestamp(1594033168, 848710897); //(crate chrono)

which then, for example, be could followed by:

println!("{}", file_datestamp.format("%Y-%m-%d@%H:%M:%S"));

to give what I asked for:- 2020-07-06@10:59:28. Hopefully NEVER 'summer time corrected', am/pm involved, timezone ambiguous, or anything else similar to confuse exactly 'when' this means. Simple sorting by this parameter should put a list of results into the order the files were last modified as real time progressed. Yet it is human understandable, and no spaces to cause future record parsing problems.

However, in rust I am not used to having to parse out the two numbers out of the 'SystemTime' type myself, with all the format/error variations it could get up to. To say nothing of my inferior unoptimized coding skills with rust. I feel sure there would be something (probably) obvious that I am missing to do this much more concisely, quickly and efficiently.

I have tried to implement:-
pub fn timestamp(&self) -> i64
(Returns the number of non-leap seconds since January 1, 1970 0:00:00 UTC (aka "UNIX timestamp").) and
pub fn timestamp_nanos(&self) -> i64
(Returns the number of non-leap-nanoseconds since January 1, 1970 UTC)
found in: chrono::DateTime - Rust
with every 'use' at the top I can think of:-

let file_timestamp_sec=file_last_modified.timestamp();
let file_timestamp_nanos=file_last_modified.timestamp_nanos();

but I get:-
error[E0599]: no method named timestamp found for type std::time::SystemTime in the current scope

Thank you very much in advance. (I never get on with or really understand up-voting or down-voting social implication systems.)

Yogi39

How? I cannot find 'start new thread' button anywhere!

Yogi39

Click on this to go to the help category:

image

then click this in the top right:

image

1 Like

Please don't use this thread to ask for help, post your own in the #help category. I'm flagging this thread for mod attention so it can be locked to prevent further confusion.

2 Likes