Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
6c02e81c
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6c02e81c
编写于
11月 10, 2013
作者:
J
Jay Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add docs for traits Exponential, Hyperbolic, BitCount.
上级
f4bedded
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
44 addition
and
2 deletion
+44
-2
src/libstd/num/mod.rs
src/libstd/num/mod.rs
+44
-2
未找到文件。
src/libstd/num/mod.rs
浏览文件 @
6c02e81c
...
...
@@ -299,13 +299,20 @@ pub trait Trigonometric {
/// Simultaneously computes the sine and cosine of the number.
#[inline(always)]
pub
fn
sin_cos
<
T
:
Trigonometric
>
(
value
:
T
)
->
(
T
,
T
)
{
value
.sin_cos
()
}
/// A trait exponential functions.
pub
trait
Exponential
{
/// Returns `e^(self)`, (the exponential function).
fn
exp
(
&
self
)
->
Self
;
/// Returns 2 raised to the power of the number, `2^(self)`.
fn
exp2
(
&
self
)
->
Self
;
/// Returns the natural logarithm of the number.
fn
ln
(
&
self
)
->
Self
;
/// Returns the logarithm of the number with respect to an arbitrary base.
fn
log
(
&
self
,
base
:
&
Self
)
->
Self
;
/// Returns the base 2 logarithm of the number.
fn
log2
(
&
self
)
->
Self
;
/// Returns the base 10 logarithm of the number.
fn
log10
(
&
self
)
->
Self
;
}
...
...
@@ -323,19 +330,26 @@ pub trait Exponential {
/// Returns the base 10 logarithm of the number.
#[inline(always)]
pub
fn
log10
<
T
:
Exponential
>
(
value
:
T
)
->
T
{
value
.log10
()
}
/// A trait hyperbolic functions.
pub
trait
Hyperbolic
:
Exponential
{
/// Hyperbolic sine function.
fn
sinh
(
&
self
)
->
Self
;
/// Hyperbolic cosine function.
fn
cosh
(
&
self
)
->
Self
;
/// Hyperbolic tangent function.
fn
tanh
(
&
self
)
->
Self
;
/// Inverse hyperbolic sine function.
fn
asinh
(
&
self
)
->
Self
;
/// Inverse hyperbolic cosine function.
fn
acosh
(
&
self
)
->
Self
;
/// Inverse hyperbolic tangent function.
fn
atanh
(
&
self
)
->
Self
;
}
/// Hyperbolic cosine function.
#[inline(always)]
pub
fn
sinh
<
T
:
Hyperbolic
>
(
value
:
T
)
->
T
{
value
.sinh
()
}
/// Hyperbolic sine function.
#[inline(always)]
pub
fn
sinh
<
T
:
Hyperbolic
>
(
value
:
T
)
->
T
{
value
.sinh
()
}
/// Hyperbolic cosine function.
#[inline(always)]
pub
fn
cosh
<
T
:
Hyperbolic
>
(
value
:
T
)
->
T
{
value
.cosh
()
}
/// Hyperbolic tangent function.
#[inline(always)]
pub
fn
tanh
<
T
:
Hyperbolic
>
(
value
:
T
)
->
T
{
value
.tanh
()
}
...
...
@@ -374,7 +388,10 @@ pub trait Real: Signed
fn
ln_10
()
->
Self
;
// Angular conversions
/// Convert degrees to radians.
fn
to_degrees
(
&
self
)
->
Self
;
/// Convert radians to degrees.
fn
to_radians
(
&
self
)
->
Self
;
}
...
...
@@ -404,9 +421,34 @@ pub trait Bitwise: Not<Self>
+
Shl
<
Self
,
Self
>
+
Shr
<
Self
,
Self
>
{}
/// A trait for common counting operations on bits.
pub
trait
BitCount
{
/// Returns the number of bits set in the number.
///
/// # Example
///
/// ```rust
/// let n = 0b0101000u16;
/// assert_eq!(n.population_count(), 2);
/// ```
fn
population_count
(
&
self
)
->
Self
;
/// Returns the number of leading zeros in the number.
///
/// # Example
///
/// ```rust
/// let n = 0b0101000u16;
/// assert_eq!(n.leading_zeros(), 10);
/// ```
fn
leading_zeros
(
&
self
)
->
Self
;
/// Returns the number of trailing zeros in the number.
///
/// # Example
///
/// ```rust
/// let n = 0b0101000u16;
/// assert_eq!(n.trailing_zeros(), 3);
/// ```
fn
trailing_zeros
(
&
self
)
->
Self
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录