@@ -47,9 +47,8 @@ impl EncoderDictionary<'static> {
4747 /// [`EncoderDictionary::try_copy`] for a dictionary you did not make
4848 /// yourself.
4949 pub fn copy ( dictionary : & [ u8 ] , level : i32 ) -> Self {
50- Self {
51- cdict : zstd_safe:: create_cdict ( dictionary, level) ,
52- }
50+ Self :: try_copy ( dictionary, level)
51+ . expect ( "zstd returned null pointer when creating dict" )
5352 }
5453
5554 /// Creates a prepared dictionary for compression, or an error if zstd
@@ -77,9 +76,7 @@ impl<'a> EncoderDictionary<'a> {
7776 /// If zstd cannot load the dictionary. Use [`EncoderDictionary::try_new`]
7877 /// for a dictionary you did not make yourself.
7978 pub fn new ( dictionary : & ' a [ u8 ] , level : i32 ) -> Self {
80- Self {
81- cdict : zstd_safe:: CDict :: create_by_reference ( dictionary, level) ,
82- }
79+ Self :: try_new ( dictionary, level) . expect ( "zstd returned null pointer" )
8380 }
8481
8582 #[ cfg( feature = "experimental" ) ]
@@ -119,9 +116,8 @@ impl DecoderDictionary<'static> {
119116 /// [`DecoderDictionary::try_copy`] for a dictionary you did not make
120117 /// yourself.
121118 pub fn copy ( dictionary : & [ u8 ] ) -> Self {
122- Self {
123- ddict : zstd_safe:: DDict :: create ( dictionary) ,
124- }
119+ Self :: try_copy ( dictionary)
120+ . expect ( "zstd returned null pointer when creating dict" )
125121 }
126122
127123 /// Create a prepared dictionary for decompression, or an error if zstd
@@ -147,9 +143,7 @@ impl<'a> DecoderDictionary<'a> {
147143 /// If zstd cannot load the dictionary. Use [`DecoderDictionary::try_new`]
148144 /// for a dictionary you did not make yourself.
149145 pub fn new ( dict : & ' a [ u8 ] ) -> Self {
150- Self {
151- ddict : zstd_safe:: DDict :: create_by_reference ( dict) ,
152- }
146+ Self :: try_new ( dict) . expect ( "zstd returned null pointer" )
153147 }
154148
155149 #[ cfg( feature = "experimental" ) ]
0 commit comments