mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Gary Guo <gary@garyguo.net>
To: Heghedus Razvan <heghedus.razvan@protonmail.com>
Cc: "Thomas Gleixner" <tglx@linutronix.de>,
	"Asahi Lina" <lina@asahilina.net>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Wedson Almeida Filho" <wedsonaf@gmail.com>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"John Stultz" <jstultz@google.com>,
	"Stephen Boyd" <sboyd@kernel.org>,
	linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
	asahi@lists.linux.dev
Subject: Re: [PATCH] rust: time: New module for timekeeping functions
Date: Wed, 22 Feb 2023 19:55:37 +0000	[thread overview]
Message-ID: <20230222195537.3462c1c3.gary@garyguo.net> (raw)
In-Reply-To: <p7e4M5-kxxScH56bBMtlzht2_m33oSfMPHtExSVbDn0WIPYBEbiJjr2NvNhqCJotFhmYqH5h27EWPDhfSmmST0D-dSU1Alq4_BzDQUR48FA=@protonmail.com>

On Tue, 21 Feb 2023 21:33:42 +0000
Heghedus Razvan <heghedus.razvan@protonmail.com> wrote:

> On Tuesday, February 21st, 2023 at 8:45 PM, Thomas Gleixner <tglx@linutronix.de> wrote:
> 
> > That's the same the Rust std time semantics:
> > 
> > Duration = Instance - Instance valid
> > Duration = Systemtime - SystemTime valid
> > Duration = Systemtime - Instance invalid
> > 
> > No?
> >   
> I agree with Thomas on this one. The Rust type system is really powerful and we should take advantage of it. Time deltas can be enforced to be from the same clock at compile time.
> Just for the sake of it, I wrote a small example on how this can be achieve: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=1d0f70bb5329b181f203ce7270e2957a
> 

`NowTime` don't need the type parameter. Here's a slightly more polished
version (also with names changed a bit so it looks more "Rusty"):

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=83702f491050da1c67ab9aa129103f7d

Best,
Gary

  parent reply	other threads:[~2023-02-22 19:55 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-21  7:06 Asahi Lina
2023-02-21  7:25 ` Eric Curtin
2023-02-21 11:23 ` Björn Roy Baron
2023-02-21 12:32 ` Thomas Gleixner
2023-02-21 14:06   ` Boqun Feng
2023-02-21 16:02     ` Thomas Gleixner
2023-02-21 16:31       ` Asahi Lina
2023-02-21 18:45         ` Thomas Gleixner
2023-02-21 21:33           ` Heghedus Razvan
2023-02-22  0:01             ` Thomas Gleixner
2023-02-22 19:55             ` Gary Guo [this message]
2023-02-21 22:29           ` Miguel Ojeda
2023-02-22  0:24             ` Thomas Gleixner
2023-02-22  2:54               ` Boqun Feng
2023-02-22  4:45                 ` Asahi Lina
2023-02-22  5:20                   ` Boqun Feng
2023-02-22  6:52                   ` Heghedus Razvan
2023-02-22 12:29                   ` Miguel Ojeda
2023-02-22 12:28               ` Miguel Ojeda
2023-02-21 16:27     ` Asahi Lina
2023-02-21 16:37       ` Asahi Lina
2023-02-21 19:00       ` Thomas Gleixner
2023-02-21 19:49         ` Boqun Feng
2023-02-22  4:56         ` Asahi Lina
2023-02-22  8:33           ` Thomas Gleixner
2023-02-21 17:13   ` Josh Stone
2023-02-21 21:46     ` Thomas Gleixner
2023-02-22  9:43       ` Gaelan Steele

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230222195537.3462c1c3.gary@garyguo.net \
    --to=gary@garyguo.net \
    --cc=alex.gaynor@gmail.com \
    --cc=asahi@lists.linux.dev \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=heghedus.razvan@protonmail.com \
    --cc=jstultz@google.com \
    --cc=lina@asahilina.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=sboyd@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=wedsonaf@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®