@@ -273,7 +273,10 @@ pub trait Real
273
273
/// Take the square root of a number.
274
274
///
275
275
/// Returns NaN if `self` is a negative floating-point number.
276
- /// If `self` is negative, but not floating-point, the implementation may panic.
276
+ ///
277
+ /// # Panics
278
+ ///
279
+ /// If the implementing type doesn't support NaN, this method should panic if `self < 0`.
277
280
///
278
281
/// ```
279
282
/// use num_traits::real::Real;
@@ -320,6 +323,10 @@ pub trait Real
320
323
321
324
/// Returns the natural logarithm of the number.
322
325
///
326
+ /// # Panics
327
+ ///
328
+ /// If `self <= 0` and this type does not support a NaN representation, this function should panic.
329
+ ///
323
330
/// ```
324
331
/// use num_traits::real::Real;
325
332
///
@@ -336,6 +343,10 @@ pub trait Real
336
343
337
344
/// Returns the logarithm of the number with respect to an arbitrary base.
338
345
///
346
+ /// # Panics
347
+ ///
348
+ /// If `self <= 0` and this type does not support a NaN representation, this function should panic.
349
+ ///
339
350
/// ```
340
351
/// use num_traits::real::Real;
341
352
///
@@ -355,6 +366,10 @@ pub trait Real
355
366
356
367
/// Returns the base 2 logarithm of the number.
357
368
///
369
+ /// # Panics
370
+ ///
371
+ /// If `self <= 0` and this type does not support a NaN representation, this function should panic.
372
+ ///
358
373
/// ```
359
374
/// use num_traits::real::Real;
360
375
///
@@ -369,6 +384,11 @@ pub trait Real
369
384
370
385
/// Returns the base 10 logarithm of the number.
371
386
///
387
+ /// # Panics
388
+ ///
389
+ /// If `self <= 0` and this type does not support a NaN representation, this function should panic.
390
+ ///
391
+ ///
372
392
/// ```
373
393
/// use num_traits::real::Real;
374
394
///
@@ -535,6 +555,11 @@ pub trait Real
535
555
/// the range [-pi/2, pi/2] or NaN if the number is outside the range
536
556
/// [-1, 1].
537
557
///
558
+ /// # Panics
559
+ ///
560
+ /// If this type does not support a NaN representation, this function should panic
561
+ /// if the number is outside the range [-1, 1].
562
+ ///
538
563
/// ```
539
564
/// use num_traits::real::Real;
540
565
/// use std::f64;
@@ -552,6 +577,11 @@ pub trait Real
552
577
/// the range [0, pi] or NaN if the number is outside the range
553
578
/// [-1, 1].
554
579
///
580
+ /// # Panics
581
+ ///
582
+ /// If this type does not support a NaN representation, this function should panic
583
+ /// if the number is outside the range [-1, 1].
584
+ ///
555
585
/// ```
556
586
/// use num_traits::real::Real;
557
587
/// use std::f64;
@@ -645,6 +675,11 @@ pub trait Real
645
675
/// Returns `ln(1+n)` (natural logarithm) more accurately than if
646
676
/// the operations were performed separately.
647
677
///
678
+ /// # Panics
679
+ ///
680
+ /// If this type does not support a NaN representation, this function should panic
681
+ /// if `self-1 <= 0`.
682
+ ///
648
683
/// ```
649
684
/// use num_traits::real::Real;
650
685
/// use std::f64;
0 commit comments