Skip to content

Commit

Permalink
Document conditional compilation of 128-bit methods
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed May 19, 2018
1 parent 1698757 commit 080b4a6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
12 changes: 10 additions & 2 deletions serde/src/de/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,9 @@ pub trait Deserializer<'de>: Sized {

serde_if_integer128! {
/// Hint that the `Deserialize` type is expecting an `i128` value.
///
/// This method is available only on Rust compiler versions >=1.26. The
/// default behavior unconditionally returns an error.
fn deserialize_i128<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>
Expand Down Expand Up @@ -917,6 +920,9 @@ pub trait Deserializer<'de>: Sized {

serde_if_integer128! {
/// Hint that the `Deserialize` type is expecting an `u128` value.
///
/// This method is available only on Rust compiler versions >=1.26. The
/// default behavior unconditionally returns an error.
fn deserialize_u128<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>
Expand Down Expand Up @@ -1275,7 +1281,8 @@ pub trait Visitor<'de>: Sized {
serde_if_integer128! {
/// The input contains a `i128`.
///
/// The default implementation fails with a type error.
/// This method is available only on Rust compiler versions >=1.26. The
/// default implementation fails with a type error.
fn visit_i128<E>(self, v: i128) -> Result<Self::Value, E>
where
E: Error,
Expand Down Expand Up @@ -1334,7 +1341,8 @@ pub trait Visitor<'de>: Sized {
serde_if_integer128! {
/// The input contains a `u128`.
///
/// The default implementation fails with a type error.
/// This method is available only on Rust compiler versions >=1.26. The
/// default implementation fails with a type error.
fn visit_u128<E>(self, v: u128) -> Result<Self::Value, E>
where
E: Error,
Expand Down
6 changes: 6 additions & 0 deletions serde/src/ser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,9 @@ pub trait Serializer: Sized {
/// #
/// # fn main() {}
/// ```
///
/// This method is available only on Rust compiler versions >=1.26. The
/// default behavior unconditionally returns an error.
fn serialize_i128(self, v: i128) -> Result<Self::Ok, Self::Error> {
let _ = v;
Err(Error::custom("i128 is not supported"))
Expand Down Expand Up @@ -646,6 +649,9 @@ pub trait Serializer: Sized {
/// #
/// # fn main() {}
/// ```
///
/// This method is available only on Rust compiler versions >=1.26. The
/// default behavior unconditionally returns an error.
fn serialize_u128(self, v: u128) -> Result<Self::Ok, Self::Error> {
let _ = v;
Err(Error::custom("u128 is not supported"))
Expand Down

0 comments on commit 080b4a6

Please sign in to comment.