Showing 2 of 2 files from the diff.
Newly tracked file
awc/src/request.rs changed.

@@ -554,8 +554,9 @@
Loading
554 554
        self
555 555
    }
556 556
557 -
    /// This method calls provided closure with builder reference if value is
558 -
    /// true.
557 +
    /// This method calls provided closure with builder reference if value is `true`.
558 +
    #[doc(hidden)]
559 +
    #[deprecated = "Use an if statement."]
559 560
    pub fn if_true<F>(&mut self, value: bool, f: F) -> &mut Self
560 561
    where
561 562
        F: FnOnce(&mut ResponseBuilder),
@@ -566,8 +567,9 @@
Loading
566 567
        self
567 568
    }
568 569
569 -
    /// This method calls provided closure with builder reference if value is
570 -
    /// Some.
570 +
    /// This method calls provided closure with builder reference if value is `Some`.
571 +
    #[doc(hidden)]
572 +
    #[deprecated = "Use an if-let construction."]
571 573
    pub fn if_some<T, F>(&mut self, value: Option<T>, f: F) -> &mut Self
572 574
    where
573 575
        F: FnOnce(T, &mut ResponseBuilder),

@@ -354,8 +354,9 @@
Loading
354 354
        self
355 355
    }
356 356
357 -
    /// This method calls provided closure with builder reference if
358 -
    /// value is `true`.
357 +
    /// This method calls provided closure with builder reference if value is `true`.
358 +
    #[doc(hidden)]
359 +
    #[deprecated = "Use an if statement."]
359 360
    pub fn if_true<F>(self, value: bool, f: F) -> Self
360 361
    where
361 362
        F: FnOnce(ClientRequest) -> ClientRequest,
@@ -367,8 +368,9 @@
Loading
367 368
        }
368 369
    }
369 370
370 -
    /// This method calls provided closure with builder reference if
371 -
    /// value is `Some`.
371 +
    /// This method calls provided closure with builder reference if value is `Some`.
372 +
    #[doc(hidden)]
373 +
    #[deprecated = "Use an if-let construction."]
372 374
    pub fn if_some<T, F>(self, value: Option<T>, f: F) -> Self
373 375
    where
374 376
        F: FnOnce(T, ClientRequest) -> ClientRequest,
@@ -601,20 +603,27 @@
Loading
601 603
602 604
    #[actix_rt::test]
603 605
    async fn test_basics() {
604 -
        let mut req = Client::new()
606 +
        let req = Client::new()
605 607
            .put("/")
606 608
            .version(Version::HTTP_2)
607 609
            .set(header::Date(SystemTime::now().into()))
608 610
            .content_type("plain/text")
609 -
            .if_true(true, |req| req.header(header::SERVER, "awc"))
610 -
            .if_true(false, |req| req.header(header::EXPECT, "awc"))
611 -
            .if_some(Some("server"), |val, req| {
612 -
                req.header(header::USER_AGENT, val)
613 -
            })
614 -
            .if_some(Option::<&str>::None, |_, req| {
615 -
                req.header(header::ALLOW, "1")
616 -
            })
617 -
            .content_length(100);
611 +
            .header(header::SERVER, "awc");
612 +
613 +
        let req = if let Some(val) = Some("server") {
614 +
            req.header(header::USER_AGENT, val)
615 +
        } else {
616 +
            req
617 +
        };
618 +
619 +
        let req = if let Some(_val) = Option::<&str>::None {
620 +
            req.header(header::ALLOW, "1")
621 +
        } else {
622 +
            req
623 +
        };
624 +
625 +
        let mut req = req.content_length(100);
626 +
618 627
        assert!(req.headers().contains_key(header::CONTENT_TYPE));
619 628
        assert!(req.headers().contains_key(header::DATE));
620 629
        assert!(req.headers().contains_key(header::SERVER));
@@ -622,6 +631,7 @@
Loading
622 631
        assert!(!req.headers().contains_key(header::ALLOW));
623 632
        assert!(!req.headers().contains_key(header::EXPECT));
624 633
        assert_eq!(req.head.version, Version::HTTP_2);
634 +
625 635
        let _ = req.headers_mut();
626 636
        let _ = req.send_body("");
627 637
    }
Files Coverage
actix-files/src 0.00%
actix-http/src 37.77%
actix-multipart/src 0.00%
actix-web-actors/src 0.00%
awc/src 17.98%
src 87.07%
tests 100.00%
actix-web-codegen/src/route.rs 0.00%
Project Totals (126 files) 53.82%
1
ignore: # ignore codecoverage on following paths
2
  - "**/tests"
3
  - "test-server"
4
  - "**/benches"
5
  - "**/examples"
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading