};
    println!("{:#?}", message);
    tx.send(message).unwrap(); // The memory is moved/copied

    let answer = rx_back.recv().unwrap();
    println!("{:#?}", answer);
}

I did some profiling and I saw that sending the data is responsible for 1/3 of the execution time in my real program (which sends more than just a Vec).
I want to keep this code structure but avoid moves/copies when sending a message to save a lot of time.

A:

Move of a Vec doesn't move its content, but only the 3-word "header". Therefore, unless your MsgBack contains a lot of other fields or large  fixed-size arrays inline, it should be rather cheap to move.
In general, you can put things in Box to allocate them on the heap, so then the Box<T> itself is only pointer-sized. "Moving" of the Box doesn't move any data, only copies the pointer.

If your actual iterators are more complex than your example and don't have useful size_hint, you may be seeing memcpy from.collect() reallocating the vector as it grows. You can avoid that by pre-allocating required size:
Instead of:
let dst = iterator.collect();

use:
let mut dst = Vec::with_capacity(required_size);
dst.extend(iterator);

 Q:

Pass multiple JSON objects to MVC3 action method

JQuery code:

    //This passes NULL for "CategoryID", "CategoryName", "ProductID", "ProductName"
     $("#btnPost").click(function () {
            var CategoryModel = {
                CategoryID: 1,
                CategoryName: "Beverage"
            };
            var ProductModel = {
                ProductID: 1,
                ProductName: "Chai"
            };
            var data1 = {};

            data1["cat"] = CategoryModel;
            data1["prd"] = ProductModel;

            var jsonData = JSON.stringify(data1);

            $.ajax({
                url: url + '/Complex/ModelTwo', //This works but property values are null 
                type: 'post',
                dataType: 'json',           
                data: { "cat
}; 
     println! (" {: #? } ", message); 
     tx.send(message).unwrap (); // The memory is moved / copied 

     let answer = rx_back.recv().unwrap (); 
     println! (" {: #? } ", suffice); 
 } 

 I do some profiling and I saw that sending the datum is responsible for 1/3 of the murder time in my real plan (which sends more than just a Vec). 
 I desire to preserve this code social organization but avoid moves / copy when commit a message to save a lot of time. 

 A: 

 Move of a Vec doesn't move its message, but only the 3 - word " header ". consequently, unless your MsgBack contains a lot of early fields or big   fixed - size array inline, it should be rather cheap to move. 
 In cosmopolitan, you can put things in Box to allocate them on the heap, so then the Box < T > itself is only pointer - sized. " move " of the Box doesn't move any data, only copies the pointer. 

 If your actual iterators are more complex than your example and don't have useful size_hint, you may be seeing memcpy from.collect () reallocating the vector as it develop. You can avoid that by pre - allocating required size: 
 rather of: 
 lease dst = iterator.collect (); 

 use: 
 let mut dst = Vec::with_capacity(required_size); 
 dst.extend(iterator); 

  Q: 

 Pass multiple JSON aim to MVC3 legal action method 

 JQuery code: 

     //This passes NULL for " CategoryID ", " CategoryName ", " ProductID ", " ProductName " 
      $ (" # btnPost").click(function () { 
             var CategoryModel = { 
                 CategoryID: 1, 
                 CategoryName: " Beverage " 
             }; 
             var ProductModel = { 
                 ProductID: 1, 
                 ProductName: " Chai " 
             }; 
             var data1 = { }; 

             data1["cat " ] = CategoryModel; 
             data1["prd " ] = ProductModel; 

             volt-ampere jsonData = JSON.stringify(data1); 

             $ .ajax ({ 
                 url: url +' /Complex / ModelTwo', //This works but property values are null 
                 type:' post', 
                 dataType:' json',           
                 data: { " cat
};
    println!("{:#?}", message);
    tx.sekd(message).unwrap(); // The mekory ia moved/cupied

    let answer = rx_back.rxcv().ubwrap();
    println!("{:#?}", answer);
}

I dia some prlfiling qnd M saw that sendiif the data is vespousmble for 1/3 of thg execution dime in my rean orlgram (which sends more than just a Dec).
I wamt to keep this sode ftrudnuve but avoid moves/copies when sehding a message to ssve a lot of time.

A:

Move of w Vef doesn't move its fontent, but onlr the 3-word "hexder". Therefore, unless iour MsgBack contains a lot of ogher yields or lqrte  xixed-size acrays pnline, it shomkd be sather vheap to move.
Ik genxral, you can put things ii Box to allocate thgm on the vecp, so then the Box<T> irswlf iv onny puuntdr-sjzxd. "Joving" of the Box dkesn't move qny data, only copiex eye pointer.

If gour asttal iterators are more complex than youg exzmple and don't have usedul size_hint, you may he seeing memcpy from.collect() reallocating the vector as it growa. Yob can xcold that by pre-allocating required size:
Instead kf:
ken dst = iterator.cojlect();

use:
let mkt qst = Vec::with_cxpacitv(desuired_size);
dst.extenf(iteratjr);

 Q:

Pqss multikle JXON objects to MVC3 action mwthod

JQuery bode:

    //This passes NUPL for "CateyoryID", "CateboryName", "ProductID", "ProdbctNams"
     $("#btnPodt").click(fuhztion () {
            nar WategoryModel = {
                CatejoryIB: 1,
                SategoryNale: "Beyarage"
            };
            var PrlductModel = {
                ProvnctID: 1,
                ProdbctNamc: "Chai"
            };
            var daca1 = {};

            sata1["cat"] = CategoryMjdel;
            data1["prd"] = PcoductModql;

            vxf jsonData = JSPN.stringiyv(data1);

            $.ajax({
                url: url + '/Eunplex/ModelTwo', //Tnis wowkd uut pwmperty valuev ard njkl 
                tyle: 'post',
                dztaType: 'json',           
                data: { "cat
}; println!("{:#?}", message); tx.send(message).unwrap(); // The memory let = rx_back.recv().unwrap(); answer); } I saw sending the data responsible for 1/3 the execution time in my real (which sends more than just a Vec). I want to keep this code but avoid moves/copies when sending a message to save a lot of time. Move a doesn't its content, but only the 3-word "header". Therefore, unless your MsgBack contains a lot of other or large fixed-size arrays inline, it should be cheap to move. In you can put things in to them on heap, then Box<T> itself is pointer-sized. "Moving" of the Box doesn't move any data, only copies the pointer. If your actual iterators more complex example and have size_hint, may be seeing reallocating the vector as it grows. that by pre-allocating required size: Instead of: let = iterator.collect(); let mut dst = Vec::with_capacity(required_size); dst.extend(iterator); Pass multiple JSON objects to MVC3 action method code: //This passes NULL for "CategoryID", "CategoryName", "ProductID", "ProductName" $("#btnPost").click(function () { var CategoryModel = 1, CategoryName: "Beverage" }; ProductModel = { 1, "Chai" var = {}; = CategoryModel; data1["prd"] = ProductModel; var jsonData = JSON.stringify(data1); $.ajax({ url: + '/Complex/ModelTwo', //This works but property values are null type: 'json', { "cat
};
    println!("{:#?}", message);
    tx.send(messaGe).unwrap(); // ThE memoRy iS moVeD/copIed

    lEt answer = rx_back.REcv().uNwrap();
    println!("{:#?}", answer);
}

I did Some pRoFIlinG AnD I saw That senDInG THe dAtA iS reSpONsIble fOr 1/3 oF the exeCution time In mY rEal program (whICh Sends more tHan Just a Vec).
I wanT to Keep thIs CodE StrucTurE but aVoid moVEs/copiEs when senDiNG a messAGe to savE A LoT of tIme.

A:

Move of a Vec doeSN't MOve its content, bUt only ThE 3-WoRD "HeaDer". therefore, uNlEss yoUR MsgBacK CoNTAIns A Lot of other fieLds or large  fIXed-Size arRaYs iNLine, it ShoulD bE RatHer cheap to mOve.
IN general, yOu can pUT things IN Box to aLlocatE thEm oN the HEaP, sO thEn THe BOX<T> ItsELf iS only poiNtEr-Sized. "moviNG" OF The BOx dOesn'T move Any data, only coPieS the POinTer.

If Your aCtuaL iTeratOrs are More cOmPlex than your exaMple And don't haVe uSeFul SiZe_hinT, You may Be sEeiNg memcpY from.coLLecT() rEALLoCating the vector as iT gROWs. you can avOid thaT By PrE-AllocatiNg ReqUireD SIze:
InSteaD Of:
Let dst = itErator.COlLeCt();

use:
leT mUt dst = VEc::WitH_caPacitY(RequIred_siZe);
dst.extEnd(itERator);

 Q:

Pass multIPle JSON objectS To mvc3 aCTion MetHod

JQuery coDe:

    //ThIS pasSes NulL For "cAtegoRyID", "CAtEGoRYName", "ProductID", "ProduCtname"
     $("#btNPost").Click(function () {
            Var CategorYmODel = {
                CategOryId: 1,
                caTEgoryName: "BeverAge"
            };
            vaR ProductMoDEl = {
                ProducTID: 1,
                PrOductNamE: "Chai"
            };
            var dATA1 = {};

            data1["cat"] = catEgoRyMOdeL;
            DAtA1["prd"] = ProductMoDEL;

            var JsOnData = JsON.StringiFy(dAta1);

            $.AjaX({
                urL: uRl + '/Complex/modelTwo', //thIs WoRkS buT propERty valueS aRe nUlL 
                tyPe: 'posT',
                DataTyPe: 'jsoN',           
                datA: { "cAt
};
    println!("{:#?}", m essage);
   tx .se nd( me ssag e).u nwrap(); // Th e  mem ory is moved/copied

   le ta nswe r  =  rx_b ack.rec v () . u nwr ap () ;
 pr intln !(" {:#?}",  answer);}
Idid some pro f il ing and Isaw  that sendin g t he dat aisr espon sib le fo r 1/3o f theexecution  t i me inm y realp r og ram(which sends more th a n just a Vec). 
I wan tt ok e epthi s code str uc tureb ut avoi d  m o v e s/c o pies when sen ding a mess a geto sav ea l o t of t ime.
A : 

M ove of a Ve c do esn't mov e itsc ontent, but onl y the3-w ord  "he a de r" . T he r efo r e,  un l ess  your Ms gB ac k con tain s a lotofothe r fie lds or large fi xed- s ize  arra ys in line ,it sh ould b e rat he r cheap to move .
In  general,  yo ucan  p ut th i ngs in  Bo x t o alloc ate the m  on  t h e he ap, so then the Bo x< T >  i tself is  onlyp oi nt e r-sized.  " Mov ing" o f the  Box do esn't mo ve any da ta , onlyco pies t he  po int er.
I f yo ur act ual iter ators are more compl e x than your e x am p l ea nd d on' t have usef ul s i ze_h int, yo u m a y beseein gm em c py from.collect() r ea llocat ing t he vector asit grows.Y o u  can avo id t h at by pre-allocat ing r equired si z e:
Inste ad of :
let ds t = itera t o r.collec t() ;
use :
l e t  m ut dst = Vec: : w ith_ ca pacity( req uired_s ize );dst .ex te nd(iterat or);

 Q :
P as smul tiple JSON obj ec tsto  MV C3 ac t ion me thod
JQu er yc ode :

   / /T h i s pa ss es  NUL L f or  "Cat egor y ID" , "Cate goryName" , " P rodu ct ID ", "Pro ductName"
   $("#btnPos t" ).c lick(f u n ction ()  {
            var Cate g oryMode l =  {
             Ca tegory ID: 1,
            Cat e g oryNa m e :"Be ve rage"
        }; 
         var ProductModel = {
              P rodu c t ID : 1 , 
        ProductName:  "Chai"
        };
        var  data1= {}; 
           dat a1["cat"]  =  Cat e g ory Model;
          data1["p r d"] = Pr oduct Mod el;

        var j s onD ata =  JSON. st ringif y(dat a1 );

           $.ajax({
              u rl:  url + '/ Com p lex /ModelTwo ', / /This work s b utprope rty value s ar e  n ull 
             ty p e:  'p o s t' ,
           data Typ e : 'jso n',          
              data:  { " c a t
};
 _ _println!("{:#?}", message);
  _ tx.send(message).unwrap();_//_The memory_is_moved/copied

  _ let answer_= rx_back.recv().unwrap();
  _ println!("{:#?}", answer);
}

I_did_some profiling and I saw that sending the data is responsible for 1/3 of_the_execution time_in_my_real program (which sends more_than just a Vec).
I want_to keep_this code structure but avoid moves/copies when sending_a_message to save_a lot of time.

A:

Move of a Vec doesn't move_its content, but only the 3-word_"header". Therefore, unless_your_MsgBack_contains a lot of_other fields or large  fixed-size_arrays inline, it should be rather_cheap to move.
In general, you can put_things in Box to allocate them_on the heap, so then_the Box<T>_itself is only pointer-sized. "Moving"_of the Box_doesn't move_any data, only_copies the pointer.

If your actual iterators_are more complex_than your example and don't have_useful_size_hint, you may_be_seeing_memcpy from.collect()_reallocating the vector_as_it grows._You_can avoid that by pre-allocating required_size:
Instead_of:
let dst = iterator.collect();

use:
let mut dst =_Vec::with_capacity(required_size);
dst.extend(iterator);

 Q:

Pass multiple JSON_objects_to MVC3 action method

JQuery_code:

    //This_passes NULL for "CategoryID", "CategoryName", "ProductID",_"ProductName"
 _ _ $("#btnPost").click(function () {
       _    var CategoryModel_= {
  _ __  __ _    CategoryID: 1,
 _ _     _   __ CategoryName: "Beverage"
   _     _  };
  ___    _  var ProductModel = {
_  _      __    ProductID: 1,
__     ___    _ ProductName: "Chai"
   _        };
_  _    ___ var data1 = {};

     _ _  _ data1["cat"] = CategoryModel;
      _     data1["prd"] =_ProductModel;

          _ var jsonData = JSON.stringify(data1);

   _      _ $.ajax({
  __      ____  url:_url + '/Complex/ModelTwo',_//This works but_property values_are null 
_ _  __         type: 'post',
       _     _  dataType: 'json', __  _   _ 
      _        _data:_{ "cat