@@ -96,12 +96,12 @@ pub struct Argument<'a> {
9696#[ rustc_diagnostic_item = "ArgumentMethods" ]
9797impl Argument < ' _ > {
9898 #[ inline]
99- fn new < ' a , T > ( x : & ' a T , f : fn ( & T , & mut Formatter < ' _ > ) -> Result ) -> Argument < ' a > {
99+ const fn new < ' a , T > ( x : & ' a T , f : fn ( & T , & mut Formatter < ' _ > ) -> Result ) -> Argument < ' a > {
100100 Argument {
101101 // INVARIANT: this creates an `ArgumentType<'a>` from a `&'a T` and
102102 // a `fn(&T, ...)`, so the invariant is maintained.
103103 ty : ArgumentType :: Placeholder {
104- value : NonNull :: from ( x) . cast ( ) ,
104+ value : NonNull :: from_ref ( x) . cast ( ) ,
105105 // SAFETY: function pointers always have the same layout.
106106 formatter : unsafe { mem:: transmute ( f) } ,
107107 _lifetime : PhantomData ,
@@ -150,7 +150,7 @@ impl Argument<'_> {
150150 Self :: new ( x, UpperExp :: fmt)
151151 }
152152 #[ inline]
153- pub fn from_usize ( x : & usize ) -> Argument < ' _ > {
153+ pub const fn from_usize ( x : & usize ) -> Argument < ' _ > {
154154 Argument { ty : ArgumentType :: Count ( * x) }
155155 }
156156
@@ -181,7 +181,7 @@ impl Argument<'_> {
181181 }
182182
183183 #[ inline]
184- pub ( super ) fn as_usize ( & self ) -> Option < usize > {
184+ pub ( super ) const fn as_usize ( & self ) -> Option < usize > {
185185 match self . ty {
186186 ArgumentType :: Count ( count) => Some ( count) ,
187187 ArgumentType :: Placeholder { .. } => None ,
@@ -199,7 +199,7 @@ impl Argument<'_> {
199199 /// println!("{f}");
200200 /// ```
201201 #[ inline]
202- pub fn none ( ) -> [ Self ; 0 ] {
202+ pub const fn none ( ) -> [ Self ; 0 ] {
203203 [ ]
204204 }
205205}
@@ -216,7 +216,7 @@ impl UnsafeArg {
216216 /// See documentation where `UnsafeArg` is required to know when it is safe to
217217 /// create and use `UnsafeArg`.
218218 #[ inline]
219- pub unsafe fn new ( ) -> Self {
219+ pub const unsafe fn new ( ) -> Self {
220220 Self { _private : ( ) }
221221 }
222222}
0 commit comments