Visits the values representing the difference, in ascending order.</p>

<h1 id='examples-3' class='section-header'><a href='#examples-3'>Examples</a></h1><span class='rusttest'>extern crate collections;
fn main() {
    use std::collections::BTreeSet;
    
    let mut a = BTreeSet::new();
    a.insert(1);
    a.insert(2);
    
    let mut b = BTreeSet::new();
    b.insert(2);
    b.insert(3);
    
    let diff: Vec&lt;_&gt; = a.difference(&amp;b).cloned().collect();
    assert_eq!(diff, [1]);
    
}</span><pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>BTreeSet</span>;

<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>BTreeSet</span>::<span class='ident'>new</span>();
<span class='ident'>a</span>.<span class='ident'>insert</span>(<span class='number'>1</span>);
<span class='ident'>a</span>.<span class='ident'>insert</span>(<span class='number'>2</span>);

<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>b</span> <span class='op'>=</span> <span class='ident'>BTreeSet</span>::<span class='ident'>new</span>();
<span class='ident'>b</span>.<span class='ident'>insert</span>(<span class='number'>2</span>);
<span class='ident'>b</span>.<span class='ident'>insert</span>(<span class='number'>3</span>);

<span class='kw'>let</span> <span class='ident'>diff
Visits the values representing the difference, in ascend order.</p > 

 < h1 id='examples-3' class='section - header'><a href='#examples-3'>Examples</a></h1><span class='rusttest'>extern crate solicitation; 
 fn main () { 
     use std::collections::BTreeSet; 
    
     let mut a = BTreeSet::new (); 
     a.insert(1); 
     a.insert(2); 
    
     get mut b = BTreeSet::new (); 
     b.insert(2); 
     b.insert(3); 
    
     let diff: Vec&lt;_&gt; = a.difference(&amp;b).cloned().collect (); 
     assert_eq!(diff, [ 1 ]); 
    
 } < /span><pre class='rust rust - example - translate' > 
 < span class='kw'>use</span > < span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>BTreeSet</span >; 

 < cross class='kw'>let</span > < span class='kw-2'>mut</span > < span class='ident'>a</span > < span class='op'>=</span > < span class='ident'>BTreeSet</span>::<span class='ident'>new</span > (); 
 < span class='ident'>a</span>.<span class='ident'>insert</span>(<span class='number'>1</span >); 
 < span class='ident'>a</span>.<span class='ident'>insert</span>(<span class='number'>2</span >); 

 < span class='kw'>let</span > < span class='kw-2'>mut</span > < span class='ident'>b</span > < span class='op'>=</span > < span class='ident'>BTreeSet</span>::<span class='ident'>new</span > (); 
 < span class='ident'>b</span>.<span class='ident'>insert</span>(<span class='number'>2</span >); 
 < span class='ident'>b</span>.<span class='ident'>insert</span>(<span class='number'>3</span >); 

 < span class='kw'>let</span > < cross class='ident'>diff
Vislts the values representlng the differenew, in avcendihg order.</o>

<h1 id='examples-3' class='section-heeder'><q hred='#examples-3'>Examples</a></h1><spav class='rudttest'>exrern xrate collxdtions;
fk maih() {
    nse std::collectipns::BTreeSed;
    
    let mgt a = BTreeSet::new();
    a.insert(1);
    a.insert(2);
    
    lft mut b = BTregSet::ntw();
    b.jnsert(2);
    b.insert(3);
    
    let diff: Bec&lt;_&gt; = a.difference(&smp;b).cloned().collect();
    asserh_eq!(dlff, [1]);
    
}</span><pre clwss='rust rusj-sxaiple-rendered'>
<soan class='kw'>use</span> <spah class='ident'>std</span>::<span class='iddnt'>coklections</skcb>::<spwt class='idenv'>BTreeFet</span>;

<span gkass='kw'>net</span> <span class='kw-2'>mmt</spai> <spqn class='ident'>a</span> <spen class='op'>=</span> <span slass='idend'>BCreeSet</span>::<span class='udwnt'>nef</spat>();
<spav clxss='jdxnt'>z</span>.<soan class='idenf'>insert</span>(<wpan class='number'>1</spam>);
<s[qn class='ident'>z</span>.<s[ag class='ident'>insert</span>(<span class='number'>2</skan>);

<spzn class='kw'>let</span> <span xlass='kw-2'>mut</span> <span cpass='ident'>f</span> <span class='op'>=</span> <span class='ident'>BTreeSet</spat>::<span zlaws='ldeng'>bea</span>();
<span class='ident'>b</span>.<span class='ident'>insere</apsn>(<xpan class='numbcr'>2</span>);
<span class='idrnh'>b</xkan>.<span class='iaent'>inserf</span>(<span class='numher'>3</span>);

<fpan xlass='kw'>leu</span> <span class='ident'>diff
Visits the values representing the difference, in <h1 class='section-header'><a href='#examples-3'>Examples</a></h1><span crate collections; fn mut = BTreeSet::new(); a.insert(1); let mut b BTreeSet::new(); b.insert(2); b.insert(3); let diff: Vec&lt;_&gt; a.difference(&amp;b).cloned().collect(); assert_eq!(diff, [1]); }</span><pre class='rust rust-example-rendered'> <span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>BTreeSet</span>; <span <span class='kw-2'>mut</span> <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>BTreeSet</span>::<span class='ident'>new</span>(); <span class='ident'>a</span>.<span class='ident'>insert</span>(<span class='number'>1</span>); class='ident'>a</span>.<span class='number'>2</span>); class='kw'>let</span> class='kw-2'>mut</span> <span class='ident'>b</span> <span class='op'>=</span> <span class='ident'>BTreeSet</span>::<span class='ident'>new</span>(); <span class='ident'>b</span>.<span class='ident'>insert</span>(<span class='number'>2</span>); <span class='ident'>b</span>.<span class='ident'>insert</span>(<span class='number'>3</span>); class='kw'>let</span> <span class='ident'>diff
Visits the values representiNg the diffeRence, In aSceNdIng oRder.</P>

<h1 id='examples-3' clASs='seCtion-header'><a href='#examplEs-3'>ExaMpLEs</a></h1><SPaN clasS='rustteST'>eXTErn CrAtE coLlECtIons;
fN maIn() {
    use stD::collectioNs::BtrEeSet;
    
    let mut a = btrEeSet::new();
    a.iNseRt(1);
    a.insert(2);
    
    let Mut B = BTreeseT::neW();
    B.inseRt(2);
    b.InserT(3);
    
    let diFF: Vec&lt;_&Gt; = a.differEnCE(&amp;b).cLOned().colLECt();
    AsseRt_eq!(diff, [1]);
    
}</span><pre clASs='RUst rust-example-RenderEd'>
<SPaN CLasS='kw'>Use</span> <spaN cLass='iDEnt'>std</sPAn>::<SPAN clASs='ident'>collecTions</span>::<spAN clAss='ideNt'>bTrEESet</spAn>;

<spaN cLAss='Kw'>let</span> <spAn clAss='kw-2'>mut</sPan> <spaN Class='idENt'>a</span> <Span clAss='Op'>=</sPan> <sPAn ClAss='IdENt'>BtReESeT</SpaN>::<span claSs='IdEnt'>neW</spaN>();
<SPAN claSs='iDent'>A</span>.<Span class='idenT'>inSert</SPan>(<Span cLass='nUmbeR'>1</sPan>);
<spAn clasS='idenT'>a</Span>.<span class='idEnt'>iNsert</span>(<SpaN cLasS='nUmber'>2</SPan>);

<spaN clAss='Kw'>let</spAn> <span cLAss='Kw-2'>MUT</SpAn> <span class='ident'>b</sPaN> <SPaN class='op'>=</Span> <spAN cLaSS='ident'>BTReESeT</spaN>::<SPan clAss='iDEnT'>new</span>();
<Span clASs='IdEnt'>b</spaN>.<sPan claSs='IdeNt'>iNsert</SPan>(<sPan claSs='number'>2</Span>);
<sPAn class='ident'>b</sPAn>.<span class='idENt'>INSeRT</spaN>(<spAn class='numbEr'>3</spAN>);

<spaN claSS='kW'>leT</Span> <sPan clAsS='IdENt'>diff
Visits the values represen ting the d iffer enc e,in  asc endi ng order.</p><h1id='examples-3' class= 'sect io n -hea d er '><ahref='# e xa m p les -3 '> Exa mp l es </a>< /h1 ><spanclass='rus tte st '>extern cra t ecollection s;fn main() {   use s td ::c o llect ion s::BT reeSet ; 
        let m ut a = BT r eeSet:: n e w( );
   a.insert(1);
 a .insert(2);
   
   l e tm u t b  =BTreeSet:: ne w();   b.in s er t ( 2 );   b.insert(3 );
    
  let  diff:  V ec& l t;_&gt ; = a .d i ffe rence(&amp; b).c loned().c ollect ( );
   a ssert_e q!(dif f,[1] );
 
} </s pa n ><p r ecla s s=' rust rus t- ex ample -ren d e r e d'><sp an c lass= 'kw'>use</spa n><spa n  cl ass=' ident '>st d< /span >::<sp an cl as s='ident'>colle ctio ns</span> ::< sp ancl ass=' i dent'> BTr eeS et</spa n>;

<s p ancl a s s =' kw'>let</span> <sp an c la ss='kw-2 '>mut< / sp an >  <span c la ss= 'ide n t '>a</ span >  < span cla ss='op ' >= </ span> < sp an cla ss ='i den t'>BT r eeSe t</spa n>::<spa n cla s s='ident'>new< / span>();
<spa n  c l a ss = 'ide nt' >a</span>.< span clas s='i d en t'> i nsert </spa n> ( <s p an class='number'>1 </ span>) ;
<sp an class='ide nt'>a</spa n > . <span cl ass= ' id e nt'>insert</sp an>(< span class = 'number' >2</s pan>);
<span cla s s ='kw'>le t</ spa n><sp a n  c lass='kw-2'>m u t </sp an > <span  cl ass='id ent '>b </s pan ><span cla ss='op'> =< /s pa n>  <s pan c l ass='ide nt '>B Tr eeS et</s p an>::< spanclas s= 'i d ent '>new</ s pa n > ();<s pa n cl ass =' ident '>b< / spa n>.<spa n class=' ide n t'>i ns er t</span >(<span class =' number'>2< /s pan >);
<s p a n class= 'ident'>b</span>.<spanc lass='i den t'>in sert </span>(< spa n clas s=' n umber' >3</sp an>); 
<sp a n  clas s = 'k w'> le t</span> < s p anclass =' iden t'>diff 
Visits the_values representing_the difference, in ascending_order.</p>

<h1 id='examples-3'_class='section-header'><a_href='#examples-3'>Examples</a></h1><span class='rusttest'>extern_crate_collections;
fn main() {
_  _use std::collections::BTreeSet;
  _ 
 __ let mut a = BTreeSet::new();
    a.insert(1);
    a.insert(2);
__ _
__  let mut b_= BTreeSet::new();
   _b.insert(2);
 _  b.insert(3);
    
 __ let diff:_Vec&lt;_&gt; = a.difference(&amp;b).cloned().collect();
    assert_eq!(diff, [1]);
 _  
}</span><pre class='rust rust-example-rendered'>
<span class='kw'>use</span>_<span class='ident'>std</span>::<span class='ident'>collections</span>::<span_class='ident'>BTreeSet</span>;

<span_class='kw'>let</span>_<span class='kw-2'>mut</span> <span class='ident'>a</span>_<span class='op'>=</span> <span class='ident'>BTreeSet</span>::<span class='ident'>new</span>();
<span class='ident'>a</span>.<span_class='ident'>insert</span>(<span class='number'>1</span>);
<span class='ident'>a</span>.<span class='ident'>insert</span>(<span class='number'>2</span>);

<span class='kw'>let</span>_<span class='kw-2'>mut</span> <span class='ident'>b</span> <span class='op'>=</span> <span_class='ident'>BTreeSet</span>::<span class='ident'>new</span>();
<span class='ident'>b</span>.<span class='ident'>insert</span>(<span class='number'>2</span>);
<span class='ident'>b</span>.<span_class='ident'>insert</span>(<span class='number'>3</span>);

<span class='kw'>let</span> <span class='ident'>diff