Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1632800rdb; Thu, 25 Jan 2024 01:12:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IFHWCNPqPDEljMOqoLG0mu0WWkxsyD9a1Cd0ldE0fwcFkTcZlcTPj8Z1LpqmVC9IrxW7Cn/ X-Received: by 2002:a05:620a:3944:b0:783:7a57:265d with SMTP id qs4-20020a05620a394400b007837a57265dmr912157qkn.133.1706173950956; Thu, 25 Jan 2024 01:12:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706173950; cv=pass; d=google.com; s=arc-20160816; b=i5Ikf9ozwZ/iV2Ji9tNywIJUbKk/FPTQ+Mhxcic5jXj0iXsCiu04iY8jxpLVY/HARH TBF4Ye5LgaQXTCjHfyIMInwwU2mabqoqNyZkGQ1JuhXMGNx6ryWdN0TO79XYdP+It+OK EVTSfddBftJsN5CaYoHVSJM1L7CBstrhYi3fORxVNTrhUrAoEg3Tvz1WM7MjpzebKFd9 6ojlo2iJ+Vq8FZCGj63ZhlfMSGKr5N5/2T12UeTBz+xsTDPxJTfse9CRAReLYezc4Oe9 JKKz40WI+nYgQ4tQdpprB+j7Gi9Gc+9MDg81YcwWdmwBIffL4Y2kLF8XRIyAY4ncg7cd LzNA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=0tM1J8tB5KHoGKyoGMxs1iTWky7jMmTAuWrPlK6yjZI=; fh=C06bcR/kJI09aV0r5nqUihSntI9xQ0H1ZXtQvOHzxI0=; b=QhpItvbHieWLUIULU94O0vP53fcPMlgH1nyQ32s8yxWS0tex1IUZzgrhe3pzVkA/7s 8wK9INWP/wLVbZhfPPFBD+bRVLGeIDnQqvKwpj4u9D416bdvAyrLBFoflyW5DxCXu3KH 7dhE9lPLUBA9XMA0tqQUR0Bt2ODuQBb/JiXdUgyD/BUllTOv9lhGntt3Lc4+djVSC6oC ykhqkgqXyTgw0ZHpn86Lcw6KE3rb/YA8vXWA12mZMYwyX+yPALmTrHwqKXp/ACA3kohj GPnc6Qr7rcy5yp74R3MwO3Rx7HeyJ89o4bCm2c6Cr9dF2qJSvg7n3H9HZniU3qxAjBp2 TwrA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="VYEZMrn/"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-38236-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38236-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id x19-20020ae9f813000000b007834b7bf527si12186687qkh.351.2024.01.25.01.12.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 01:12:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38236-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="VYEZMrn/"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-38236-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38236-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 33EF51C287C7 for ; Thu, 25 Jan 2024 09:10:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BC4721CA94; Thu, 25 Jan 2024 09:08:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="VYEZMrn/" Received: from mail-ua1-f46.google.com (mail-ua1-f46.google.com [209.85.222.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 855D01CA88 for ; Thu, 25 Jan 2024 09:08:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706173729; cv=none; b=OvR5WGRrzyhJO5RNkFv49neE/kDQjp6+ZE4LU0nwq3aYUSISPsIn89/jdcebseStZZNgrBYAZI6Bguj3KHdmjlLNFNJWYAj/oYCmcojtaeV301QiCCJMsx5tILo0dkiAtr3x6hobQWukvcYC+EDB9zysBd4TcU9lQzhwK1CNZTI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706173729; c=relaxed/simple; bh=DaaeOBTj4cHWJG3k51yGq2TD3ACFmgQSxId2jEXJNmw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=a2J+H4T+Sz54PXp+tRP+sjcVC9YDV5PUc72ggoehIaXH5cEzSH7AQ4dpic81pX1sR+3OnYrC9qXG54L8/JcCXxUksu1Wx5PJGpNhiqoF86l1pXkIcGLvFmxP90c1Q4ArlGv3kmzXYC68eR3lqztPhso+1wtXX4RmWyEoCo3rPQY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=VYEZMrn/; arc=none smtp.client-ip=209.85.222.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ua1-f46.google.com with SMTP id a1e0cc1a2514c-7ce603b9051so2098092241.2 for ; Thu, 25 Jan 2024 01:08:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706173727; x=1706778527; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=0tM1J8tB5KHoGKyoGMxs1iTWky7jMmTAuWrPlK6yjZI=; b=VYEZMrn/w1Y+q+tII5Ztg+rUP6CgPvjD4KSAXL+fjScAa9oF1WPVmFBqncscFjW53o 68jPvmgdShEzV0g5M2BVRPyiBi3aITrNB/0UBOt7limLRThrk+mduI1NaGAREYIN86QO YZQXjpwh/36pgvDH7GhQbf3rJV24sOPptHhXMXMUgnhQMFFsv8hpMFBBgtRXS8T/noDW 1GwTJUP6loW3Er52eB4kJpYd76oIuhzSMv7ta2tLFOYZXHSUB4cNKOKVAa//veXEKfUo cc2KFzql0/dpdtatp9OaZtOdRi+T5P8AijeW3WVPkPwVwQ9b1Bo/lkdfDywR7tibK43z 0fUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706173727; x=1706778527; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0tM1J8tB5KHoGKyoGMxs1iTWky7jMmTAuWrPlK6yjZI=; b=H8FrW2RpzLiOp7yXaaY1EKU/ri2mwUuwXC+Upc8+8uwC9m3wMUZXoA5UHBcCFAygXr s4Qpf3AU+sFQGMeGI6pXpKA37G3hhVNDgv05QzNy9HCNItKN8vzCJIK/b4Zce2o77IoK hRuJVQvxIZA2IUZev5anvaFswYHGiiUT/tdnfPPznFHUTvSQa90gLu3j+pjVpZL88RB6 wRUd4FcM86Nfj8QsJ3bgIu2rxDHoJBCfbOogljIGqNZInHZ8JO+4jQARWRaTGqOmkCiS t/q0j23roHRbgyaLriNrNyPcwOrkYVR9pBp7oxMGge6mN8gENWmrhEYvtGlyL6ztqSUW BQIw== X-Gm-Message-State: AOJu0Yw1s5qlppFNg53AprmjYY1f3wxdn2u7MAUdc4cZGjwzADtC7vni 63wh0uWmXN7ruY4NUxWoCKlE9hGNB2a6OLEcjcDZn8QnQoSQ23N8dzGmtABBmdu9/TTQefV7Y0H QqRIJz3aPEQH55/Hxv0RgF5XKw+p15Q4OfT/S X-Received: by 2002:a05:6122:380f:b0:4b7:8e5f:7782 with SMTP id em15-20020a056122380f00b004b78e5f7782mr413172vkb.8.1706173727304; Thu, 25 Jan 2024 01:08:47 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240122184608.11863-1-dakr@redhat.com> In-Reply-To: <20240122184608.11863-1-dakr@redhat.com> From: Alice Ryhl Date: Thu, 25 Jan 2024 10:08:35 +0100 Message-ID: Subject: Re: [PATCH] rust: str: add to_ascii_{upper,lower}case() to CString To: Danilo Krummrich Cc: ojeda@kernel.org, alex.gaynor@gmail.com, wedsonaf@gmail.com, boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com, benno.lossin@proton.me, a.hindborg@samsung.com, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Jan 22, 2024 at 7:46=E2=80=AFPM Danilo Krummrich = wrote: > + /// Converts the whole CString to lowercase. > + pub fn to_ascii_lowercase(&mut self) { > + self.buf.make_ascii_lowercase(); > + } > + > + /// Converts the whole CString to uppercase. > + pub fn to_ascii_uppercase(&mut self) { > + self.buf.make_ascii_uppercase(); > + } > } It looks like these methods are defined on `CString`. However, there's no requirement that you need *ownership* of the c string to change its contents - you just need mutable access. I think it would make more sense to introduce an `impl DerefMut for CString` that returns a `&mut CStr`, and then define these methods on `CStr` as `&mut self`. That way, you can still call them on `CString`, but you can also call it on other mutable c strings. Alice