@@ -514,7 +514,7 @@ impl Bson {
514
514
}
515
515
}
516
516
517
- /// Get the `ElementType` of this value.
517
+ /// Get the [ `ElementType`] of this value.
518
518
pub fn element_type ( & self ) -> ElementType {
519
519
match * self {
520
520
Bson :: Double ( ..) => ElementType :: Double ,
@@ -841,152 +841,159 @@ impl Bson {
841
841
842
842
/// Value helpers
843
843
impl Bson {
844
- /// If `Bson` is `Double`, return its value as an `f64`. Returns `None` otherwise
844
+ /// If `self` is [`Double`](Bson::Double), return its value as an `f64`. Returns [`None`]
845
+ /// otherwise.
845
846
pub fn as_f64 ( & self ) -> Option < f64 > {
846
847
match * self {
847
848
Bson :: Double ( v) => Some ( v) ,
848
849
_ => None ,
849
850
}
850
851
}
851
852
852
- /// If `Bson` is `String`, return its value as a `&str`. Returns `None` otherwise
853
+ /// If `self` is [`String`](Bson::String), return its value as a `&str`. Returns [`None`]
854
+ /// otherwise.
853
855
pub fn as_str ( & self ) -> Option < & str > {
854
856
match * self {
855
857
Bson :: String ( ref s) => Some ( s) ,
856
858
_ => None ,
857
859
}
858
860
}
859
861
860
- /// If `Bson ` is `String`, return a mutable reference to its value as a `str`. Returns `None`
861
- /// otherwise
862
+ /// If `self ` is [ `String`](Bson::String) , return a mutable reference to its value as a [ `str`].
863
+ /// Returns [`None`] otherwise.
862
864
pub fn as_str_mut ( & mut self ) -> Option < & mut str > {
863
865
match * self {
864
866
Bson :: String ( ref mut s) => Some ( s) ,
865
867
_ => None ,
866
868
}
867
869
}
868
870
869
- /// If `Bson ` is `Array`, return its value. Returns `None` otherwise
871
+ /// If `self ` is [ `Array`](Bson::Array) , return its value. Returns [ `None`] otherwise.
870
872
pub fn as_array ( & self ) -> Option < & Array > {
871
873
match * self {
872
874
Bson :: Array ( ref v) => Some ( v) ,
873
875
_ => None ,
874
876
}
875
877
}
876
878
877
- /// If `Bson` is `Array`, return a mutable reference to its value. Returns `None` otherwise
879
+ /// If `self` is [`Array`](Bson::Array), return a mutable reference to its value. Returns
880
+ /// [`None`] otherwise.
878
881
pub fn as_array_mut ( & mut self ) -> Option < & mut Array > {
879
882
match * self {
880
883
Bson :: Array ( ref mut v) => Some ( v) ,
881
884
_ => None ,
882
885
}
883
886
}
884
887
885
- /// If `Bson ` is `Document`, return its value. Returns `None` otherwise
888
+ /// If `self ` is [ `Document`](Bson::Document) , return its value. Returns [ `None`] otherwise.
886
889
pub fn as_document ( & self ) -> Option < & Document > {
887
890
match * self {
888
891
Bson :: Document ( ref v) => Some ( v) ,
889
892
_ => None ,
890
893
}
891
894
}
892
895
893
- /// If `Bson` is `Document`, return a mutable reference to its value. Returns `None` otherwise
896
+ /// If `self` is [`Document`](Bson::Document), return a mutable reference to its value. Returns
897
+ /// [`None`] otherwise.
894
898
pub fn as_document_mut ( & mut self ) -> Option < & mut Document > {
895
899
match * self {
896
900
Bson :: Document ( ref mut v) => Some ( v) ,
897
901
_ => None ,
898
902
}
899
903
}
900
904
901
- /// If `Bson ` is `Bool` , return its value. Returns `None` otherwise
905
+ /// If `self ` is [`Boolean`](Bson::Boolean) , return its value. Returns [ `None`] otherwise.
902
906
pub fn as_bool ( & self ) -> Option < bool > {
903
907
match * self {
904
908
Bson :: Boolean ( v) => Some ( v) ,
905
909
_ => None ,
906
910
}
907
911
}
908
912
909
- /// If `Bson ` is `I32` , return its value. Returns `None` otherwise
913
+ /// If `self ` is [`Int32`](Bson::Int32) , return its value. Returns [ `None`] otherwise.
910
914
pub fn as_i32 ( & self ) -> Option < i32 > {
911
915
match * self {
912
916
Bson :: Int32 ( v) => Some ( v) ,
913
917
_ => None ,
914
918
}
915
919
}
916
920
917
- /// If `Bson ` is `I64` , return its value. Returns `None` otherwise
921
+ /// If `self ` is [`Int64`](Bson::Int64) , return its value. Returns [ `None`] otherwise.
918
922
pub fn as_i64 ( & self ) -> Option < i64 > {
919
923
match * self {
920
924
Bson :: Int64 ( v) => Some ( v) ,
921
925
_ => None ,
922
926
}
923
927
}
924
928
925
- /// If `Bson ` is `Objectid` , return its value. Returns `None` otherwise
929
+ /// If `self ` is [`ObjectId`](Bson::ObjectId) , return its value. Returns [ `None`] otherwise.
926
930
pub fn as_object_id ( & self ) -> Option < oid:: ObjectId > {
927
931
match * self {
928
932
Bson :: ObjectId ( v) => Some ( v) ,
929
933
_ => None ,
930
934
}
931
935
}
932
936
933
- /// If `Bson` is `Objectid`, return a mutable reference to its value. Returns `None` otherwise
937
+ /// If `self` is [`ObjectId`](Bson::ObjectId), return a mutable reference to its value. Returns
938
+ /// [`None`] otherwise.
934
939
pub fn as_object_id_mut ( & mut self ) -> Option < & mut oid:: ObjectId > {
935
940
match * self {
936
941
Bson :: ObjectId ( ref mut v) => Some ( v) ,
937
942
_ => None ,
938
943
}
939
944
}
940
945
941
- /// If `Bson ` is `DateTime`, return its value. Returns `None` otherwise
946
+ /// If `self ` is [ `DateTime`](Bson::DateTime) , return its value. Returns [ `None`] otherwise.
942
947
pub fn as_datetime ( & self ) -> Option < & crate :: DateTime > {
943
948
match * self {
944
949
Bson :: DateTime ( ref v) => Some ( v) ,
945
950
_ => None ,
946
951
}
947
952
}
948
953
949
- /// If `Bson ` is `DateTime`, return a mutable reference to its value. Returns `None`
950
- /// otherwise
954
+ /// If `self ` is [ `DateTime`](Bson::DateTime) , return a mutable reference to its value. Returns
955
+ /// [`None`] otherwise.
951
956
pub fn as_datetime_mut ( & mut self ) -> Option < & mut crate :: DateTime > {
952
957
match * self {
953
958
Bson :: DateTime ( ref mut v) => Some ( v) ,
954
959
_ => None ,
955
960
}
956
961
}
957
962
958
- /// If `Bson ` is `Symbol`, return its value. Returns `None` otherwise
963
+ /// If `self ` is [ `Symbol`](Bson::Symbol) , return its value. Returns [ `None`] otherwise.
959
964
pub fn as_symbol ( & self ) -> Option < & str > {
960
965
match * self {
961
966
Bson :: Symbol ( ref v) => Some ( v) ,
962
967
_ => None ,
963
968
}
964
969
}
965
970
966
- /// If `Bson` is `Symbol`, return a mutable reference to its value. Returns `None` otherwise
971
+ /// If `self` is [`Symbol`](Bson::Symbol), return a mutable reference to its value. Returns
972
+ /// [`None`] otherwise.
967
973
pub fn as_symbol_mut ( & mut self ) -> Option < & mut str > {
968
974
match * self {
969
975
Bson :: Symbol ( ref mut v) => Some ( v) ,
970
976
_ => None ,
971
977
}
972
978
}
973
979
974
- /// If `Bson ` is `Timestamp`, return its value. Returns `None` otherwise
980
+ /// If `self ` is [ `Timestamp`](Bson::Timestamp) , return its value. Returns [ `None`] otherwise.
975
981
pub fn as_timestamp ( & self ) -> Option < Timestamp > {
976
982
match * self {
977
983
Bson :: Timestamp ( timestamp) => Some ( timestamp) ,
978
984
_ => None ,
979
985
}
980
986
}
981
987
982
- /// If `Bson ` is `Null`, return its value . Returns `None` otherwise
988
+ /// If `self ` is [ `Null`](Bson::Null) , return `()` . Returns [ `None`] otherwise.
983
989
pub fn as_null ( & self ) -> Option < ( ) > {
984
990
match * self {
985
991
Bson :: Null => Some ( ( ) ) ,
986
992
_ => None ,
987
993
}
988
994
}
989
995
996
+ /// If `self` is [`DbPointer`](Bson::DbPointer), return its value. Returns [`None`] otherwise.
990
997
pub fn as_db_pointer ( & self ) -> Option < & DbPointer > {
991
998
match self {
992
999
Bson :: DbPointer ( ref db_pointer) => Some ( db_pointer) ,
0 commit comments