Skip to content

Commit

Permalink
Remove most uses of extern crate (#82)
Browse files Browse the repository at this point in the history
This leaves only one for `enum_primitive` as that needs further
work (and ideally switching to a maintained crate that does that
sort of thing).
  • Loading branch information
waywardmonkeys authored Dec 10, 2024
1 parent ea6fb89 commit fe17693
Show file tree
Hide file tree
Showing 23 changed files with 30 additions and 78 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ dxf = { version = "0.5.0", features = ["serialize"] }
> Note that `serde` support is intended to aid in debugging and since the serialized format is heavily
dependent on the layout of the structures, it may change at any time.

And finally add:

``` rust
extern crate dxf;
```

# Documentation

See the documentation [here](https://docs.rs/dxf/) on docs.rs.
Expand Down
6 changes: 3 additions & 3 deletions build/entity_generator.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
extern crate xmltree;
use self::xmltree::Element;
use xmltree::Element;

use crate::ExpectedType;

Expand Down Expand Up @@ -39,8 +38,9 @@ use crate::helper_functions::*;
use crate::tables::*;
use crate::x_data;
use enum_primitive::FromPrimitive;
use crate::enums::*;
use crate::enum_primitive::FromPrimitive;
use crate::objects::*;
".trim_start());
fun.push('\n');
Expand Down
11 changes: 4 additions & 7 deletions build/header_generator.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
extern crate xmltree;
use self::xmltree::Element;
use xmltree::Element;

use crate::ExpectedType;

Expand Down Expand Up @@ -32,15 +31,13 @@ use crate::{
use crate::helper_functions::*;
use crate::enums::*;
use crate::enum_primitive::FromPrimitive;
use enum_primitive::FromPrimitive;
use std::time::Duration;
extern crate chrono;
use self::chrono::{DateTime, Local, Utc};
use chrono::{DateTime, Local, Utc};
extern crate uuid;
use self::uuid::Uuid;
use uuid::Uuid;
".trim_start());
generate_struct(&mut fun, &element);

Expand Down
8 changes: 3 additions & 5 deletions build/object_generator.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
extern crate xmltree;
use self::xmltree::Element;
use xmltree::Element;

use crate::ExpectedType;

Expand Down Expand Up @@ -46,11 +45,10 @@ use crate::x_data;
use crate::entities::*;
use crate::enums::*;
use crate::enum_primitive::FromPrimitive;
use enum_primitive::FromPrimitive;
use std::collections::HashMap;
extern crate chrono;
use self::chrono::{DateTime, Local};
use chrono::{DateTime, Local};
".trim_start());
fun.push('\n');
generate_base_object(&mut fun, &element);
Expand Down
7 changes: 2 additions & 5 deletions build/table_generator.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
extern crate xmltree;
use self::xmltree::Element;
use xmltree::Element;

use crate::ExpectedType;

Expand All @@ -17,8 +16,6 @@ pub fn generate_tables(generated_dir: &Path) {
fun.push_str("
// The contents of this file are automatically generated and should not be modified directly. See the `build` directory.
extern crate itertools;
use crate::{
CodePair,
CodePairValue,
Expand All @@ -41,7 +38,7 @@ use crate::extension_data;
use crate::x_data;
use crate::enums::*;
use crate::enum_primitive::FromPrimitive;
use enum_primitive::FromPrimitive;
".trim_start());
fun.push('\n');
generate_table_items(&mut fun, &element);
Expand Down
3 changes: 1 addition & 2 deletions build/test_helper_generator.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
extern crate xmltree;
use self::xmltree::Element;
use xmltree::Element;

use crate::xml_helpers::*;

Expand Down
3 changes: 1 addition & 2 deletions build/xml_helpers.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
extern crate xmltree;
use self::xmltree::Element;
use crate::other_helpers::*;
use crate::ExpectedType;
use xmltree::Element;

pub fn attr(element: &Element, name: &str) -> String {
match element.attributes.get(name) {
Expand Down
4 changes: 0 additions & 4 deletions dxf2json/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
extern crate dxf;
extern crate serde;
extern crate serde_json;

use dxf::Drawing;
use std::env;
use std::fs::File;
Expand Down
2 changes: 0 additions & 2 deletions examples/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate dxf;

mod block_examples;
mod line_type_examples;

Expand Down
1 change: 1 addition & 0 deletions src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ mod tests {
use crate::enums::*;
use crate::helper_functions::tests::*;
use crate::*;
use float_cmp::approx_eq;

fn read_blocks_section(content: Vec<CodePair>) -> Drawing {
let mut pairs = vec![
Expand Down
4 changes: 1 addition & 3 deletions src/code_pair.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
extern crate byteorder;

use std::fmt;
use std::fmt::{Debug, Display, Formatter};

use self::byteorder::{BigEndian, ByteOrder};
use byteorder::{BigEndian, ByteOrder};

use crate::{CodePairValue, DxfError, DxfResult, Handle};

Expand Down
3 changes: 1 addition & 2 deletions src/code_pair_writer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::io::Write;

extern crate byteorder;
use self::byteorder::{LittleEndian, WriteBytesExt};
use byteorder::{LittleEndian, WriteBytesExt};

use crate::code_pair_value::{escape_control_characters, escape_unicode_to_ascii};
use crate::enums::AcadVersion;
Expand Down
6 changes: 2 additions & 4 deletions src/drawing.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
extern crate encoding_rs;
use self::encoding_rs::Encoding;
use encoding_rs::Encoding;

extern crate image;
use self::image::DynamicImage;
use image::DynamicImage;

use crate::code_pair_put_back::CodePairPutBack;
use crate::drawing_item::{DrawingItem, DrawingItemMut};
Expand Down
3 changes: 1 addition & 2 deletions src/dxb_writer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::io::Write;

extern crate byteorder;
use self::byteorder::{LittleEndian, WriteBytesExt};
use byteorder::{LittleEndian, WriteBytesExt};

use crate::{Drawing, DxfResult};

Expand Down
1 change: 1 addition & 0 deletions src/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1628,6 +1628,7 @@ mod tests {
use crate::helper_functions::tests::*;
use crate::objects::*;
use crate::*;
use float_cmp::approx_eq;

fn read_entity(entity_type: &str, body: Vec<CodePair>) -> Entity {
let mut pairs = vec![CodePair::new_str(0, entity_type)];
Expand Down
2 changes: 0 additions & 2 deletions src/enums.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate num;

use crate::{DxfError, DxfResult};
use std::fmt;

Expand Down
1 change: 1 addition & 0 deletions src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ mod tests {
use crate::enums::*;
use crate::helper_functions::tests::*;
use crate::*;
use float_cmp::approx_eq;
use std::time::Duration;

#[test]
Expand Down
14 changes: 5 additions & 9 deletions src/helper_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@ use std::io;
use std::io::Read;
use std::time::Duration as StdDuration;

extern crate byteorder;
use self::byteorder::{ByteOrder, LittleEndian};
use byteorder::{ByteOrder, LittleEndian};

extern crate chrono;
use self::chrono::prelude::*;
use self::chrono::Duration as ChronoDuration;
use chrono::prelude::*;
use chrono::Duration as ChronoDuration;

extern crate encoding_rs;
use self::encoding_rs::Encoding;
use encoding_rs::Encoding;

extern crate uuid;
use self::uuid::Uuid;
use uuid::Uuid;

use enum_primitive::FromPrimitive;

Expand Down
15 changes: 0 additions & 15 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@
//! > Note that `serde` support is intended to aid in debugging and since the serialized format is heavily
//! dependent on the layout of the structures, it may change at any time.
//!
//! And finally add:
//!
//! ``` rust
//! extern crate dxf;
//! ```
//!
//! # Examples
//!
//! Open a DXF file from disk:
Expand Down Expand Up @@ -115,14 +109,9 @@
#![warn(clippy::doc_markdown)]

extern crate encoding_rs;

#[macro_use]
extern crate enum_primitive;

extern crate image;
extern crate itertools;

mod code_pair;
pub use crate::code_pair::CodePair;

Expand Down Expand Up @@ -229,8 +218,4 @@ mod object_iter;
#[cfg(test)]
include!(concat!(env!("OUT_DIR"), "/generated/tests/mod.rs"));

#[cfg(test)]
#[macro_use]
extern crate float_cmp;

mod misc_tests;
3 changes: 1 addition & 2 deletions src/misc_tests/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use crate::*;
use std::io::{BufReader, Cursor, Seek, SeekFrom};
use std::str::from_utf8;

extern crate image;
use self::image::{DynamicImage, GenericImageView};
use image::{DynamicImage, GenericImageView};

#[test]
fn read_string_with_control_characters() {
Expand Down
1 change: 0 additions & 1 deletion src/misc_tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::process::Command;
use std::thread::panicking;
use std::time::SystemTime;

extern crate glob;
use glob::glob;

struct Oda {
Expand Down
3 changes: 1 addition & 2 deletions src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use enum_primitive::FromPrimitive;
use itertools::Itertools;
use std::ops::Add;

extern crate chrono;
use self::chrono::Duration;
use chrono::Duration;

use crate::{
CodePair, Color, DataTableValue, DxfError, DxfResult, Point, SectionTypeSettings,
Expand Down
1 change: 1 addition & 0 deletions src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ mod tests {
use crate::objects::*;
use crate::tables::*;
use crate::*;
use float_cmp::approx_eq;

fn read_table(table_name: &str, value_pairs: Vec<CodePair>) -> Drawing {
let mut pairs = vec![
Expand Down

0 comments on commit fe17693

Please sign in to comment.