Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB362C636D7 for ; Wed, 22 Feb 2023 00:02:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230078AbjBVACB (ORCPT ); Tue, 21 Feb 2023 19:02:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229546AbjBVAB7 (ORCPT ); Tue, 21 Feb 2023 19:01:59 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28F062ED58; Tue, 21 Feb 2023 16:01:59 -0800 (PST) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1677024117; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=xMGpa08Mw3PGW7iuLitm7PdtQJcfT87dyawJM52k+dU=; b=MLRi3hb8X5D/TpPJf1xZH6FufcfF1nogAzow0RQ4qibu3fHoWq8BUChC+xpokPf1UwbI19 uDIqwXHlL3WiQyR5OlFSOl8Ua4hbtrFXhd6LxIgOI2J3cBb7alyaR2+8RTvKAycjEYoFAo apHv9u54r5LoPjaK2GNiA8GBe0beGgbzn7QMPW8c4K5F9zOrcqmZTfl09BdyfS4vMxDypu wivxsYkl7X34CsTHgOUjBFN9UElRum0bDPmn0JwYFztaoMsouko6M7QxCYYc9urW/ZHNTU EmtOngioXVeuJwXSPS6xserCcE28HxGsqWLANZ4LyzAm5wCCRdpkMV9Kt+KgqA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1677024117; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=xMGpa08Mw3PGW7iuLitm7PdtQJcfT87dyawJM52k+dU=; b=HTJMzuLacM9f1T894foCtmTb5LoD1SKgQ/AGK1UWgN7Vt4zfuKK+4V1gA5yWSrVVOMh792 NEOgjOiqYk+8+ZCQ== To: Heghedus Razvan Cc: Asahi Lina , Boqun Feng , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Gary Guo , =?utf-8?Q?Bj=C3=B6rn?= Roy Baron , John Stultz , Stephen Boyd , 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 In-Reply-To: References: <20230221-gpu-up-time-v1-1-bf8fe74b7f55@asahilina.net> <87v8jvnqq4.ffs@tglx> <87h6vfnh0f.ffs@tglx> <7b93bf74-abdc-f8c1-9a12-7c7f080f9e19@asahilina.net> <87edqioo1e.ffs@tglx> Date: Wed, 22 Feb 2023 01:01:56 +0100 Message-ID: <87r0uimutn.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 21 2023 at 21:33, Heghedus Razvan wrote: > On Tuesday, February 21st, 2023 at 8:45 PM, Thomas Gleixner 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 Cute. This code makes even sense to Rustagnostics like me. Thanks, tglx