Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp10242579rwp; Thu, 20 Jul 2023 17:31:06 -0700 (PDT) X-Google-Smtp-Source: APBJJlEbFO1747DIZ9WvI2Nggrt3X0aUsEG3/KjzNcbCqSEIzpzkURBZZKQC3I5mTIdwI6ZY6OIC X-Received: by 2002:aa7:d98b:0:b0:51a:5ebe:4ab9 with SMTP id u11-20020aa7d98b000000b0051a5ebe4ab9mr327372eds.14.1689899466542; Thu, 20 Jul 2023 17:31:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689899466; cv=none; d=google.com; s=arc-20160816; b=hqiAqB032yuG7wVbaawM3K9m3V5Q8bxUcpNom6Sb0rYvebPbCxwl/JrK5Wf1MD4R1P ktP2P5w2RW+BSFtCz/rTmd1PoCo0XIwnzuisAsqj2Ibyupghjs3iuUKiXHWXys6rgv57 XMBPUPXfx7G2Y8tzru9h2z85ICQjbbKFBOBtYrS4q3falkBDUlCHQYcSyhbF+MeJJ6UM XbZhDTgawCZE3KjSNXNKrXegfWKLRwC97ZfgQYEifLQgry8qqrlTDfRA1ST7aE2tst6c YOOfuuZlwGXxgQ2zVzUQIzhE83LjWiArmq8NGqYrhU22vbHwM3XH2yPGm/vlJukC2wop K/HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=VeltO9PjU3Yqjbdf6G2ByRCeL2krBZR93hUWkSW1uTM=; fh=QIytb8Pc/tNQKCXmppbqLtpd0hrzmewt+SvaGVZrVJI=; b=huCQVTsgICkwkgr8Gjh1D15aKZ78pe1sC3YSGweM/bTaQ/DBlRMAGBwwA/NOWhXREH d667+RoaUgdlsc7Gz1Ct9ud0m6Oz/NIgoCkSsvsvZgG3r+hNOZRjwnv+LDQs5sms6tKi WduhnvBbWJ/P5SrdoxJRa1Ndj4jmbo9uBwfc7oK9060kzTo9H5mk3WOQkLRWRPHyuACf pfLGz+aVTmFsPgbtK+Dso0zD1bOd2HEQYEhbJDSCJrhIOmd7cy7ccqKzDjTON5yfbDNo 8MYWDz4nmhsbty7uO+QHCld3NXe4TE+hlqPADhqV5PkFP6cQ/00PeFkYii86H2JJx8uX PzTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=idOpyw0M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w17-20020aa7dcd1000000b00514a4541769si1505878edu.81.2023.07.20.17.30.42; Thu, 20 Jul 2023 17:31:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=idOpyw0M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229586AbjGUA0T (ORCPT + 99 others); Thu, 20 Jul 2023 20:26:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229888AbjGUA0R (ORCPT ); Thu, 20 Jul 2023 20:26:17 -0400 Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7689C270D; Thu, 20 Jul 2023 17:25:52 -0700 (PDT) Received: by mail-oi1-x22a.google.com with SMTP id 5614622812f47-3a1e6022b93so992628b6e.1; Thu, 20 Jul 2023 17:25:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689899127; x=1690503927; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=VeltO9PjU3Yqjbdf6G2ByRCeL2krBZR93hUWkSW1uTM=; b=idOpyw0MlYvoYEDzVBsa0aQ2Rn8KOjoNY5Vlxc6aWEqi3bsw/DA80M9us1xnvIFPsh Lce2jPTHoBCzlsROrUuJ+En5Zh98C3lPDQfYh8PauAWX/Vqc23jSqCkBjmY7QUDsCJhd l8vB+08ezhvBz1G/Vnq4j6EBmRCtWEOKNi3inRJMCz9oSWOOG/+vv1JuadQMeZiTv3qH NqEV5u0ynugT1k3TXOBa+KipJ99ZzxxTYDvnqkeCkYynckplRpSgIyswg0vBX89h+Qym OXEz7fk/bM3kHmoIYMK9E4jif74mLwCPRDx2YcK9LA6D7mWStMzryrAMnkHy+2pi0RDP cdxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689899127; x=1690503927; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=VeltO9PjU3Yqjbdf6G2ByRCeL2krBZR93hUWkSW1uTM=; b=TaGjivAp39ceUKIYT1wdM7Y7WIRtpu7iTKVzmNkZX2ugr2UbfzWqxyi5l2J4XFdb/F Rfa3XsCXoW05k3uvgeoeAAV2xUdDP2F5yEN1Bp/hBLc7b6ltvfSNvetM/D1VY92j4Uya y47xbnUnTnAm3qGjUFyasT7NKx/puIsUJ9eVgM2qZV0BJgD1r2QESb5IPPIBCWgyEQC2 PYOLRkjMn9xe0xYk/tp1V9k7cpG9EEDQGhEi0FnVf35xw+EQJXBIoVysrhIJ2EAIUbIH M9viEo+4+uYeSYuVZJduHoJZtYYurHB3tJcPJdELzO9RLQeYRMlSFp6KZRzC+7X0A4uS Bzkw== X-Gm-Message-State: ABy/qLb9wpeFnWUm0d8ZnG8VsSLEkYRWoXN07HMVxFP6PCKw4RzQdAmj Fqe3+78U0XLuKE811C88hSo= X-Received: by 2002:a05:6808:c6:b0:3a3:660c:bdb0 with SMTP id t6-20020a05680800c600b003a3660cbdb0mr450469oic.54.1689899127705; Thu, 20 Jul 2023 17:25:27 -0700 (PDT) Received: from [192.168.54.90] (static.220.238.itcsa.net. [190.15.220.238]) by smtp.gmail.com with ESMTPSA id t25-20020a056808159900b0039ee1de4e6esm928210oiw.38.2023.07.20.17.25.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 20 Jul 2023 17:25:27 -0700 (PDT) Message-ID: <486a1bce-dccf-b7a9-a600-e9b8a8f36a97@gmail.com> Date: Thu, 20 Jul 2023 10:59:05 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 07/12] rust: init: Add functions to create array initializers Content-Language: en-US To: Benno Lossin , Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor Cc: Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Alice Ryhl , Andreas Hindborg , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Asahi Lina References: <20230719141918.543938-1-benno.lossin@proton.me> <20230719141918.543938-8-benno.lossin@proton.me> From: Martin Rodriguez Reboredo In-Reply-To: <20230719141918.543938-8-benno.lossin@proton.me> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,DATE_IN_PAST_06_12, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/19/23 11:20, Benno Lossin wrote: > Add two functions `pin_init_array_from_fn` and `init_array_from_fn` that > take a function that generates initializers for `T` from usize, the added > functions then return an initializer for `[T; N]` where every element is > initialized by an element returned from the generator function. > > Suggested-by: Asahi Lina > Reviewed-by: Björn Roy Baron > Signed-off-by: Benno Lossin > --- > [...] > +/// Initializes an array by initializing each element via the provided initializer. > +/// > +/// # Examples > +/// > +/// ```rust > +/// use kernel::{error::Error, init::init_array_from_fn}; > +/// let array: Box<[usize; 1_000_000_000]>= Box::init::(init_array_from_fn(|i| i)).unwrap(); > +/// pr_info!("{array:?}"); > +/// ``` Rather than debug printing the array I'd suggest to assert the struct size or its elements instead. > [...] > + > +/// Initializes an array by initializing each element via the provided initializer. > +/// > +/// # Examples > +/// > +/// ```rust > +/// use kernel::{sync::{Arc, Mutex}, init::pin_init_array_from_fn, new_mutex}; > +/// let array: Arc<[Mutex; 1_000_000_000]>= > +/// Arc::pin_init(pin_init_array_from_fn(|i| new_mutex!(i))).unwrap(); > +/// pr_info!("{}", array.len()); > +/// ``` > [...] Same as above.