#1760 deprecate builder if-x methods

Merged Rob Ede robjtede
Coverage Reach
actix-http/src/h1/dispatcher.rs actix-http/src/h1/decoder.rs actix-http/src/h1/encoder.rs actix-http/src/h1/service.rs actix-http/src/h1/client.rs actix-http/src/h1/codec.rs actix-http/src/h1/payload.rs actix-http/src/h1/utils.rs actix-http/src/h1/mod.rs actix-http/src/h1/expect.rs actix-http/src/h1/upgrade.rs actix-http/src/header/common/content_disposition.rs actix-http/src/header/common/range.rs actix-http/src/header/common/content_range.rs actix-http/src/header/common/cache_control.rs actix-http/src/header/common/if_range.rs actix-http/src/header/common/mod.rs actix-http/src/header/common/content_type.rs actix-http/src/header/common/accept.rs actix-http/src/header/common/date.rs actix-http/src/header/common/last_modified.rs actix-http/src/header/common/allow.rs actix-http/src/header/shared/charset.rs actix-http/src/header/shared/entity.rs actix-http/src/header/shared/quality_item.rs actix-http/src/header/shared/httpdate.rs actix-http/src/header/shared/encoding.rs actix-http/src/header/map.rs actix-http/src/header/mod.rs actix-http/src/client/pool.rs actix-http/src/client/connector.rs actix-http/src/client/h1proto.rs actix-http/src/client/h2proto.rs actix-http/src/client/connection.rs actix-http/src/client/error.rs actix-http/src/client/config.rs actix-http/src/ws/codec.rs actix-http/src/ws/frame.rs actix-http/src/ws/proto.rs actix-http/src/ws/mod.rs actix-http/src/ws/mask.rs actix-http/src/ws/dispatcher.rs actix-http/src/response.rs actix-http/src/h2/dispatcher.rs actix-http/src/h2/service.rs actix-http/src/h2/mod.rs actix-http/src/encoding/encoder.rs actix-http/src/encoding/decoder.rs actix-http/src/encoding/mod.rs actix-http/src/message.rs actix-http/src/service.rs actix-http/src/body.rs actix-http/src/error.rs actix-http/src/config.rs actix-http/src/test.rs actix-http/src/builder.rs actix-http/src/request.rs actix-http/src/httpmessage.rs actix-http/src/helpers.rs actix-http/src/extensions.rs actix-http/src/time_parser.rs actix-http/src/payload.rs actix-http/src/cloneable.rs actix-http/src/httpcodes.rs actix-http/src/macros.rs src/types/json.rs src/types/payload.rs src/types/form.rs src/types/path.rs src/types/readlines.rs src/types/query.rs src/middleware/logger.rs src/middleware/normalize.rs src/middleware/defaultheaders.rs src/middleware/compress.rs src/middleware/errhandlers.rs src/middleware/condition.rs src/scope.rs src/test.rs src/request.rs src/resource.rs src/server.rs src/service.rs src/app.rs src/rmap.rs src/responder.rs src/guard.rs src/app_service.rs src/data.rs src/info.rs src/config.rs src/route.rs src/extract.rs src/request_data.rs src/handler.rs src/error.rs src/web.rs src/lib.rs awc/src/request.rs awc/src/ws.rs awc/src/sender.rs awc/src/response.rs awc/src/frozen.rs awc/src/builder.rs awc/src/connect.rs awc/src/test.rs awc/src/lib.rs awc/src/error.rs actix-files/src/named.rs actix-files/src/files.rs actix-files/src/service.rs actix-files/src/range.rs actix-files/src/chunked.rs actix-files/src/path_buf.rs actix-files/src/directory.rs actix-files/src/error.rs actix-files/src/lib.rs tests/test_server.rs tests/test_httpserver.rs actix-multipart/src/server.rs actix-multipart/src/extractor.rs actix-multipart/src/error.rs actix-web-actors/src/ws.rs actix-web-actors/src/context.rs actix-web-codegen/src/route.rs

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.

Showing 2 of 4 files from the diff.

@@ -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,27 +603,35 @@
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));
621 630
        assert!(req.headers().contains_key(header::USER_AGENT));
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
    }

Everything is accounted for!

No changes detected that need to be reviewed.
What changes does Codecov check for?
Lines, not adjusted in diff, that have changed coverage data.
Files that introduced coverage data that had none before.
Files that have missing coverage data that once were tracked.
Files Coverage
actix-files/src 0.00%
actix-http/src 38.02%
actix-multipart/src 0.00%
actix-web-actors/src 0.00%
awc/src 17.98%
src 86.61%
tests 100.00%
actix-web-codegen/src/route.rs 0.00%
Project Totals (125 files) 53.89%
Loading