[solved] Auto conversion between types


#1

I came across this type conversion in chrono.
Specifically, DateTime::from_utc(datetime: NaiveDateTime, ...).

let from: DateTime<Utc> = DateTime::from_utc(NaiveDate::from_ymd(2020, 1, 1), Utc);
let date: DateTime<Utc> = DateTime::from_utc(NaiveDateTime::from_timestamp( 8_210_298_412_799, 1_000_000_000), Utc);

It accepts NaiveDateTime (as expected) but also accepts NaiveDate. I don’t see any inheritance-like relation. What is actually going on?

Edit: Nothing wrong here. Silly of me to post such a shitty question. I was head banging (without even compiling) as the intellij-rust was not giving me error hints. So, I thought the statements were correct. Sorry. And, I cannot delete this question.


#2

If you encounter something like this again (and it works) you might want to check out https://ricardomartins.cc/2016/08/03/convenient_and_idiomatic_conversions_in_rust, which explains how something like this could work.