| "+""+(item.is_alias===true?(""+item.alias+" - see "):"")+item.displayPath+""+name+" | "+""+""+item.desc+" |
"+code.outerHTML+" |
fn:) to \
- restrict the search to a given item kind.","Accepted kinds are: fn, mod, struct, \
- enum, trait, type, macro, \
- and const.","Search functions by type signature (e.g., vec -> usize or \
- * -> vec)","Search multiple things at once by splitting your query with comma (e.g., \
- str,u8 or String,struct:Vec,test)","You can look for items with an exact name by putting double quotes around \
- your request: \"string\"","Look for items inside another one by searching for a path: vec::Vec",].map(function(x){return""+x+"
"}).join("");var div_infos=document.createElement("div");addClass(div_infos,"infos");div_infos.innerHTML="pub fn digit_to_text(digit: u8) -> Option<String>
Convert digit to words in a string.
-pub fn to_text(number: u32) -> String
Convert u32 to words in a string.
-pub fn to_text_no_seperator(number: u32) -> String
Convert u32 to words in a string.
-pub fn to_text_with_seperator(number: u32, seperator: &str) -> String
Convert u32 to words in a string seperated by a seperator.
--extern crate ntext; -use ntext::digit_to_text; -fn main() { - println!("{}",digit_to_text(1).unwrap()); - assert_eq!("two",digit_to_text(2).unwrap()); - assert_ne!("five",digit_to_text(8).unwrap()); -}
However giving the program a zero will return an empty string.
- --extern crate ntext; -use ntext::to_text; -fn main() { - println!("{}",to_text!(1312)); - assert_eq!(to_text!(1312),"onethousandthreehundredtwelve"); - println!("{}",to_text!(7123)); - assert_eq!(to_text!(7123," "),"seven thousand one hundred twenty three"); -}
This macro will also return an empty string on input zero
-| to_text | Macro which supports both seperator and without it - |
| digit_to_text | Convert digit to words in a string. - |
| to_text_no_seperator | Convert u32 to words in a string. - |
| to_text_with_seperator | Convert u32 to words in a string seperated by a seperator. - |
Redirecting to macro.to_text.html...
- - - \ No newline at end of file diff --git a/docs/doc/ntext/macro.to_text.html b/docs/doc/ntext/macro.to_text.html deleted file mode 100644 index 221f32d..0000000 --- a/docs/doc/ntext/macro.to_text.html +++ /dev/null @@ -1,11 +0,0 @@ -Macro which supports both seperator and without it
-Redirecting to ../../ntext/fn.to_text_no_seperator.html...
- - - \ No newline at end of file diff --git a/docs/doc/ntext/seperator/fn.to_text_with_seperator.html b/docs/doc/ntext/seperator/fn.to_text_with_seperator.html deleted file mode 100644 index b3d2e95..0000000 --- a/docs/doc/ntext/seperator/fn.to_text_with_seperator.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - -Redirecting to ../../ntext/fn.to_text_with_seperator.html...
- - - \ No newline at end of file diff --git a/docs/doc/ntext/sidebar-items.js b/docs/doc/ntext/sidebar-items.js deleted file mode 100644 index 73ddd95..0000000 --- a/docs/doc/ntext/sidebar-items.js +++ /dev/null @@ -1 +0,0 @@ -initSidebarItems({"fn":[["digit_to_text","Convert digit to words in a string."],["to_text_no_seperator","Convert u32 to words in a string."],["to_text_with_seperator","Convert u32 to words in a string seperated by a seperator."]],"macro":[["to_text","Macro which supports both seperator and without it"]]}); \ No newline at end of file diff --git a/docs/doc/rust-logo.png b/docs/doc/rust-logo.png deleted file mode 100644 index 74b4bd6..0000000 Binary files a/docs/doc/rust-logo.png and /dev/null differ diff --git a/docs/doc/rustdoc.css b/docs/doc/rustdoc.css deleted file mode 100644 index ecb81ce..0000000 --- a/docs/doc/rustdoc.css +++ /dev/null @@ -1 +0,0 @@ - @font-face {font-family:'Fira Sans';font-style:normal;font-weight:400;src:local('Fira Sans'),url("FiraSans-Regular.woff") format('woff');}@font-face {font-family:'Fira Sans';font-style:normal;font-weight:500;src:local('Fira Sans Medium'),url("FiraSans-Medium.woff") format('woff');}@font-face {font-family:'Source Serif Pro';font-style:normal;font-weight:400;src:local('Source Serif Pro'),url("SourceSerifPro-Regular.ttf.woff") format('woff');}@font-face {font-family:'Source Serif Pro';font-style:italic;font-weight:400;src:local('Source Serif Pro Italic'),url("SourceSerifPro-It.ttf.woff") format('woff');}@font-face {font-family:'Source Serif Pro';font-style:normal;font-weight:700;src:local('Source Serif Pro Bold'),url("SourceSerifPro-Bold.ttf.woff") format('woff');}@font-face {font-family:'Source Code Pro';font-style:normal;font-weight:400;src:url("SourceCodePro-Regular.woff") format('woff');}@font-face {font-family:'Source Code Pro';font-style:normal;font-weight:600;src:url("SourceCodePro-Semibold.woff") format('woff');}*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;}html{content:"";}@media (prefers-color-scheme:light){html{content:"light";}}@media (prefers-color-scheme:dark){html{content:"dark";}}body{font:16px/1.4 "Source Serif Pro",serif;margin:0;position:relative;padding:10px 15px 20px 15px;-webkit-font-feature-settings:"kern","liga";-moz-font-feature-settings:"kern","liga";font-feature-settings:"kern","liga";}h1{font-size:1.5em;}h2{font-size:1.4em;}h3{font-size:1.3em;}h1,h2,h3:not(.impl):not(.method):not(.type):not(.tymethod):not(.notable),h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant){font-weight:500;margin:20px 0 15px 0;padding-bottom:6px;}h1.fqn{border-bottom:1px dashed;margin-top:0;}h1.fqn>.in-band>a:hover{text-decoration:underline;}h2,h3:not(.impl):not(.method):not(.type):not(.tymethod),h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant){border-bottom:1px solid;}h3.impl,h3.method,h4.method,h3.type,h4.type,h4.associatedconstant{flex-basis:100%;font-weight:600;margin-top:16px;margin-bottom:10px;position:relative;}h3.impl,h3.method,h3.type{padding-left:15px;}h1,h2,h3,h4,.sidebar,a.source,.search-input,.content table td:first-child>a,.collapse-toggle,div.item-list .out-of-band,#source-sidebar,#sidebar-toggle,#main>ul.docblock>li>a{font-family:"Fira Sans",sans-serif;}.content ul.crate a.crate{font:16px/1.6 "Fira Sans";}ol,ul{padding-left:25px;}ul ul,ol ul,ul ol,ol ol{margin-bottom:.6em;}p{margin:0 0 .6em 0;}summary{outline:none;}code,pre,a.test-arrow{font-family:"Source Code Pro",monospace;}.docblock code,.docblock-short code{border-radius:3px;padding:0 0.1em;}.docblock pre code,.docblock-short pre code,.docblock code.spotlight{padding:0;padding-right:1ex;}.docblock code.spotlight :last-child{padding-bottom:0.6em;}pre{padding:14px;}.source .content pre{padding:20px;}img{max-width:100%;}li{position:relative;}.source .content{margin-top:50px;max-width:none;overflow:visible;margin-left:0px;min-width:70em;}nav.sub{font-size:16px;text-transform:uppercase;}.sidebar{width:200px;position:fixed;left:0;top:0;bottom:0;overflow:auto;}*{scrollbar-width:initial;}.sidebar{scrollbar-width:thin;}::-webkit-scrollbar{width:12px;}.sidebar::-webkit-scrollbar{width:8px;}::-webkit-scrollbar-track{-webkit-box-shadow:inset 0;}.sidebar .block>ul>li{margin-right:-10px;}.content,nav{max-width:960px;}.hidden{display:none !important;}.logo-container{height:100px;width:100px;position:relative;margin:20px auto;display:block;margin-top:10px;}.logo-container>img{max-width:100px;max-height:100px;position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);display:block;}.sidebar .location{border:1px solid;font-size:17px;margin:30px 10px 20px 10px;text-align:center;word-wrap:break-word;}.sidebar .version{font-size:15px;text-align:center;border-bottom:1px solid;overflow-wrap:break-word;word-wrap:break-word;word-break:break-word;}.location:empty{border:none;}.location a:first-child{font-weight:500;}.block{padding:0;margin-bottom:14px;}.block h2,.block h3{margin-top:0;margin-bottom:8px;text-align:center;}.block ul,.block li{margin:0 10px;padding:0;list-style:none;}.block a{display:block;text-overflow:ellipsis;overflow:hidden;line-height:15px;padding:7px 5px;font-size:14px;font-weight:300;transition:border 500ms ease-out;}.sidebar-title{border-top:1px solid;border-bottom:1px solid;text-align:center;font-size:17px;margin-bottom:5px;}.sidebar-links{margin-bottom:15px;}.sidebar-links>a{padding-left:10px;width:100%;}.sidebar-menu{display:none;}.content{padding:15px 0;}.source .content pre.rust{white-space:pre;overflow:auto;padding-left:0;}.rustdoc:not(.source) .example-wrap{display:inline-flex;margin-bottom:10px;position:relative;}.example-wrap{width:100%;}.example-wrap>pre.line-number{overflow:initial;border:1px solid;border-top-left-radius:5px;border-bottom-left-radius:5px;padding:13px 8px;text-align:right;}.rustdoc:not(.source) .example-wrap>pre.rust{width:100%;overflow-x:auto;}.rustdoc:not(.source) .example-wrap>pre{margin:0;}#search{margin-left:230px;position:relative;}#results{position:absolute;right:0;left:0;overflow:auto;}#results>table{width:100%;table-layout:fixed;margin-bottom:40px;}.content pre.line-numbers{float:left;border:none;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}.line-numbers span{cursor:pointer;}.docblock-short{overflow-wrap:anywhere;}.docblock-short p{display:inline;}.docblock-short p{overflow:hidden;text-overflow:ellipsis;margin:0;}.docblock-short code{white-space:pre-wrap;}.docblock h1,.docblock h2,.docblock h3,.docblock h4,.docblock h5{border-bottom:1px solid;}#main>.docblock h1{font-size:1.3em;}#main>.docblock h2{font-size:1.15em;}#main>.docblock h3,#main>.docblock h4,#main>.docblock h5{font-size:1em;}#main>h2+div,#main>h2+h3,#main>h3+div{display:none;flex-wrap:wrap;}.docblock h1{font-size:1em;}.docblock h2{font-size:0.95em;}.docblock h3,.docblock h4,.docblock h5{font-size:0.9em;}.docblock{margin-left:24px;position:relative;}.content .out-of-band{float:right;font-size:23px;margin:0px;padding:0px;font-weight:normal;}h3.impl>.out-of-band{font-size:21px;}h4.method>.out-of-band{font-size:19px;}h4>code,h3>code,.invisible>code{max-width:calc(100% - 41px);display:block;}.invisible{width:100%;display:inline-block;}.content .in-band{margin:0px;padding:0px;}.in-band>code{display:inline-block;}#main{position:relative;}#main>.since{top:inherit;font-family:"Fira Sans",sans-serif;}.content table:not(.table-display){border-spacing:0 5px;}.content td{vertical-align:top;}.content td:first-child{padding-right:20px;}.content td p:first-child{margin-top:0;}.content td h1,.content td h2{margin-left:0;font-size:1.1em;}.content tr:first-child td{border-top:0;}.docblock table{margin:.5em 0;width:calc(100% - 2px);border:1px dashed;}.docblock table td{padding:.5em;border:1px dashed;}.docblock table th{padding:.5em;text-align:left;border:1px solid;}.fields+table{margin-bottom:1em;}.content .item-list{list-style-type:none;padding:0;}.content .multi-column{-moz-column-count:5;-moz-column-gap:2.5em;-webkit-column-count:5;-webkit-column-gap:2.5em;column-count:5;column-gap:2.5em;}.content .multi-column li{width:100%;display:inline-block;}.content .method{font-size:1em;position:relative;}.content .method .where,.content .fn .where,.content .where.fmt-newline{display:block;font-size:0.8em;}.content .methods>div:not(.notable-traits){margin-left:40px;margin-bottom:15px;}.content .docblock>.impl-items{margin-left:20px;margin-top:-34px;}.content .docblock>.impl-items>h4{border-bottom:0;}.content .docblock>.impl-items .table-display{margin:0;}.content .docblock>.impl-items table td{padding:0;}.toggle-wrapper.marg-left>.collapse-toggle{left:-24px;}.content .docblock>.impl-items .table-display,.impl-items table td{border:none;}.content .item-info code{font-size:90%;}.content .item-info{position:relative;margin-left:33px;margin-top:-13px;}.sub-variant>div>.item-info{margin-top:initial;}.content .item-info::before{content:'⬑';font-size:25px;position:absolute;top:-6px;left:-19px;}.content .impl-items .method,.content .impl-items>.type,.impl-items>.associatedconstant{margin-left:20px;}.content .impl-items .docblock,.content .impl-items .item-info{margin-bottom:.6em;}.content .impl-items>.item-info{margin-left:40px;}.methods>.item-info,.content .impl-items>.item-info{margin-top:-8px;}.impl-items{flex-basis:100%;}#main>.item-info{margin-top:0;}nav:not(.sidebar){border-bottom:1px solid;padding-bottom:10px;margin-bottom:10px;}nav.main{padding:20px 0;text-align:center;}nav.main .current{border-top:1px solid;border-bottom:1px solid;}nav.main .separator{border:1px solid;display:inline-block;height:23px;margin:0 20px;}nav.sum{text-align:right;}nav.sub form{display:inline;}nav.sub,.content{margin-left:230px;}a{text-decoration:none;background:transparent;}.small-section-header:hover>.anchor{display:initial;}.in-band:hover>.anchor,.impl:hover>.anchor{display:inline-block;position:absolute;}.anchor{display:none;position:absolute;left:-7px;}.anchor.field{left:-5px;}.small-section-header>.anchor{left:-28px;padding-right:10px;}.anchor:before{content:'\2002\00a7\2002';}.docblock a:not(.srclink):not(.test-arrow):hover,.docblock-short a:not(.srclink):not(.test-arrow):hover,.item-info a{text-decoration:underline;}.invisible>.srclink,h4>code+.srclink,h3>code+.srclink{position:absolute;top:0;right:0;font-size:17px;font-weight:normal;}.block a.current.crate{font-weight:500;}.search-container{position:relative;}.search-container>div{display:inline-flex;width:calc(100% - 63px);}#crate-search{margin-top:5px;padding:6px;padding-right:19px;flex:none;border:0;border-right:0;border-radius:4px 0 0 4px;outline:none;cursor:pointer;border-right:1px solid;-moz-appearance:none;-webkit-appearance:none;text-indent:0.01px;text-overflow:"";background-repeat:no-repeat;background-color:transparent;background-size:20px;background-position:calc(100% - 1px) 56%;}.search-container>.top-button{position:absolute;right:0;top:10px;}.search-input{-moz-box-sizing:border-box !important;box-sizing:border-box !important;outline:none;border:none;border-radius:1px;margin-top:5px;padding:10px 16px;font-size:17px;transition:border-color 300ms ease;transition:border-radius 300ms ease-in-out;transition:box-shadow 300ms ease-in-out;width:100%;}#crate-search+.search-input{border-radius:0 1px 1px 0;width:calc(100% - 32px);}.search-input:focus{border-radius:2px;border:0;outline:0;}.search-results .desc{white-space:nowrap;text-overflow:ellipsis;overflow:hidden;display:block;}.search-results a{display:block;}.content .search-results td:first-child{padding-right:0;width:50%;}.content .search-results td:first-child a{padding-right:10px;}.content .search-results td:first-child a:after{clear:both;content:"";display:block;}.content .search-results td:first-child a span{float:left;}tr.result span.primitive::after{content:' (primitive type)';font-style:italic;}tr.result span.keyword::after{content:' (keyword)';font-style:italic;}body.blur>:not(#help){filter:blur(8px);-webkit-filter:blur(8px);opacity:.7;}#help{width:100%;height:100vh;position:fixed;top:0;left:0;display:flex;justify-content:center;align-items:center;}#help>div{flex:0 0 auto;box-shadow:0 0 6px rgba(0,0,0,.2);width:550px;height:auto;border:1px solid;}#help dt{float:left;clear:left;display:block;margin-right:0.5rem;}#help>div>span{text-align:center;display:block;margin:10px 0;font-size:18px;border-bottom:1px solid #ccc;padding-bottom:4px;margin-bottom:6px;}#help dd{margin:5px 35px;}#help .infos{padding-left:0;}#help h1,#help h2{margin-top:0;}#help>div div{width:50%;float:left;padding:0 20px 20px 17px;;}.stab{display:table;border-width:1px;border-style:solid;padding:3px;margin-bottom:5px;font-size:90%;}.stab p{display:inline;}.stab summary{display:list-item;}.stab .emoji{font-size:1.5em;}.module-item .stab{border-radius:3px;display:inline-block;font-size:80%;line-height:1.2;margin-bottom:0;margin-right:.3em;padding:2px;vertical-align:text-bottom;}.module-item.unstable{opacity:0.65;}.since{font-weight:normal;font-size:initial;position:absolute;right:0;top:0;}.impl-items .since,.impl .since,.methods .since{flex-grow:0;padding-left:12px;padding-right:2px;position:initial;}.impl-items .srclink,.impl .srclink,.methods .srclink{flex-grow:0;font-size:17px;font-weight:normal;}.impl-items code,.impl code,.methods code{flex-grow:1;}.impl-items h4,h4.impl,h3.impl,.methods h3{display:flex;flex-basis:100%;font-size:16px;margin-bottom:12px;justify-content:space-between;}.variants_table{width:100%;}.variants_table tbody tr td:first-child{width:1%;}td.summary-column{width:100%;}.summary{padding-right:0px;}pre.rust .question-mark{font-weight:bold;}a.test-arrow{display:inline-block;position:absolute;padding:5px 10px 5px 10px;border-radius:5px;font-size:130%;top:5px;right:5px;z-index:1;}a.test-arrow:hover{text-decoration:none;}.section-header:hover a:before{position:absolute;left:-25px;padding-right:10px;content:'\2002\00a7\2002';}.section-header:hover a{text-decoration:none;}.section-header a{color:inherit;}.collapse-toggle{font-weight:300;position:absolute;left:-23px;top:0;}h3>.collapse-toggle,h4>.collapse-toggle{font-size:0.8em;top:5px;}.toggle-wrapper>.collapse-toggle{left:-24px;margin-top:0px;}.toggle-wrapper{position:relative;margin-top:0;}.toggle-wrapper.collapsed{height:25px;transition:height .2s;margin-bottom:.6em;}.collapse-toggle>.inner{display:inline-block;width:1.2ch;text-align:center;}.collapse-toggle.hidden-default{position:relative;margin-left:20px;}.since+.srclink{display:table-cell;padding-left:10px;}.item-spacer{width:100%;height:12px;}.out-of-band>span.since{position:initial;font-size:20px;margin-right:5px;}.toggle-wrapper>.collapse-toggle{left:0;}.variant+.toggle-wrapper+.docblock>p{margin-top:5px;}.sub-variant,.sub-variant>h3{margin-top:1px !important;}#main>.sub-variant>h3{font-size:15px;margin-left:25px;margin-bottom:5px;}.sub-variant>div{margin-left:20px;margin-bottom:10px;}.sub-variant>div>span{display:block;position:relative;}.toggle-label{display:inline-block;margin-left:4px;margin-top:3px;}.enum>.toggle-wrapper+.docblock,.struct>.toggle-wrapper+.docblock{margin-left:30px;margin-bottom:20px;margin-top:5px;}.docblock>.section-header:first-child{margin-left:15px;margin-top:0;}.docblock>.section-header:first-child:hover>a:before{left:-10px;}.enum>.collapsed,.struct>.collapsed{margin-bottom:25px;}#main>.variant,#main>.structfield{display:block;}.attributes{display:block;margin-top:0px !important;margin-right:0px;margin-bottom:0px !important;margin-left:30px;}.toggle-attributes.collapsed{margin-bottom:0;}.impl-items>.toggle-attributes{margin-left:20px;}.impl-items .attributes{font-weight:500;}:target>code{opacity:1;}.information{position:absolute;left:-25px;margin-top:7px;z-index:1;}.tooltip{position:relative;display:inline-block;cursor:pointer;}.tooltip::after{display:none;text-align:center;padding:5px 3px 3px 3px;border-radius:6px;margin-left:5px;font-size:16px;}.tooltip.ignore::after{content:"This example is not tested";}.tooltip.compile_fail::after{content:"This example deliberately fails to compile";}.tooltip.should_panic::after{content:"This example panics";}.tooltip.edition::after{content:"This code runs with edition " attr(data-edition);}.tooltip::before{content:" ";position:absolute;top:50%;left:16px;margin-top:-5px;border-width:5px;border-style:solid;display:none;}.tooltip:hover::before,.tooltip:hover::after{display:inline;}.tooltip.compile_fail,.tooltip.should_panic,.tooltip.ignore{font-weight:bold;font-size:20px;}.notable-traits-tooltip{display:inline-block;cursor:pointer;}.notable-traits:hover .notable-traits-tooltiptext,.notable-traits .notable-traits-tooltiptext.force-tooltip{display:inline-block;}.notable-traits .notable-traits-tooltiptext{display:none;padding:5px 3px 3px 3px;border-radius:6px;margin-left:5px;z-index:10;font-size:16px;cursor:default;position:absolute;border:1px solid;}.notable-traits-tooltip::after{content:"\00a0\00a0\00a0";}.notable-traits .notable,.notable-traits .docblock{margin:0;}.notable-traits .docblock code.content{margin:0;padding:0;font-size:20px;}pre.rust.rust-example-rendered{position:relative;}pre.rust{tab-size:4;-moz-tab-size:4;}.search-failed{text-align:center;margin-top:20px;}.search-failed>ul{text-align:left;max-width:570px;margin-left:auto;margin-right:auto;}#titles{height:35px;}#titles>button{float:left;width:33.3%;text-align:center;font-size:18px;cursor:pointer;border:0;border-top:2px solid;}#titles>button:not(:last-child){margin-right:1px;width:calc(33.3% - 1px);}#titles>button>div.count{display:inline-block;font-size:16px;}.notable-traits{cursor:pointer;z-index:2;margin-left:5px;}h4>.notable-traits{position:absolute;left:-44px;top:2px;}#all-types{text-align:center;border:1px solid;margin:0 10px;margin-bottom:10px;display:block;border-radius:7px;}#all-types>p{margin:5px 0;}#sidebar-toggle{position:fixed;top:30px;left:300px;z-index:10;padding:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;cursor:pointer;font-weight:bold;transition:left .5s;font-size:1.2em;border:1px solid;border-left:0;}#source-sidebar{position:fixed;top:0;bottom:0;left:0;width:300px;z-index:1;overflow:auto;transition:left .5s;border-right:1px solid;}#source-sidebar>.title{font-size:1.5em;text-align:center;border-bottom:1px solid;margin-bottom:6px;}.theme-picker{position:absolute;left:211px;top:19px;}.theme-picker button{outline:none;}#settings-menu,.help-button{position:absolute;top:10px;}#settings-menu{right:0;outline:none;}.help-button{right:30px;font-family:"Fira Sans",sans-serif;text-align:center;font-size:17px;}#theme-picker,#settings-menu,.help-button{padding:4px;width:27px;height:29px;border:1px solid;border-radius:3px;cursor:pointer;}#theme-choices{display:none;position:absolute;left:0;top:28px;border:1px solid;border-radius:3px;z-index:1;cursor:pointer;}#theme-choices>button{border:none;width:100%;padding:4px 8px;text-align:center;background:rgba(0,0,0,0);}#theme-choices>button:not(:first-child){border-top:1px solid;}@media (min-width:701px){.information:first-child>.tooltip{margin-top:16px;}}@media (max-width:700px){body{padding-top:0px;}.rustdoc>.sidebar{height:45px;min-height:40px;margin:0;margin-left:-15px;padding:0 15px;position:static;z-index:11;}.sidebar>.location{float:right;margin:0px;margin-top:2px;padding:3px 10px 1px 10px;min-height:39px;background:inherit;text-align:left;font-size:24px;}.sidebar .location:empty{padding:0;}.sidebar .logo-container{width:35px;height:35px;margin-top:5px;margin-bottom:5px;float:left;margin-left:50px;}.sidebar .logo-container>img{max-width:35px;max-height:35px;}.sidebar-menu{position:fixed;z-index:10;font-size:2rem;cursor:pointer;width:45px;left:0;text-align:center;display:block;border-bottom:1px solid;border-right:1px solid;height:45px;}.rustdoc.source>.sidebar>.sidebar-menu{display:none;}.sidebar-elems{position:fixed;z-index:1;left:0;top:45px;bottom:0;overflow-y:auto;border-right:1px solid;display:none;}.sidebar>.block.version{border-bottom:none;margin-top:12px;margin-bottom:0;}nav.sub{width:calc(100% - 32px);float:right;}.content{margin-left:0px;}#main,#search{margin-top:45px;padding:0;}.content .in-band{width:100%;}.content h4>.out-of-band{position:inherit;}.toggle-wrapper>.collapse-toggle{left:0px;}.toggle-wrapper{height:1.5em;}#search{margin-left:0;}.content .impl-items .method,.content .impl-items>.type,.impl-items>.associatedconstant{display:flex;}.anchor{display:none !important;}h1.fqn{overflow:initial;}.theme-picker{left:10px;top:54px;z-index:1;}h4>.notable-traits{position:absolute;left:-22px;top:24px;}#titles>button>div.count{float:left;width:100%;}#titles{height:50px;}.sidebar.mobile{position:fixed;width:100%;margin-left:0;background-color:rgba(0,0,0,0);height:100%;}.sidebar.mobile>div.version{overflow:hidden;max-height:33px;}.sidebar{width:calc(100% + 30px);}.show-it{display:block;width:246px;}.show-it>.block.items{margin:8px 0;}.show-it>.block.items>ul{margin:0;}.show-it>.block.items>ul>li{text-align:center;margin:2px 0;}.show-it>.block.items>ul>li>a{font-size:21px;}#sidebar-filler{position:fixed;left:45px;width:calc(100% - 45px);top:0;height:45px;z-index:-1;border-bottom:1px solid;}.collapse-toggle{left:-20px;}.impl>.collapse-toggle{left:-10px;}#all-types{margin:10px;}#sidebar-toggle{top:100px;width:30px;font-size:1.5rem;text-align:center;padding:0;}#source-sidebar{z-index:11;}#main>.line-numbers{margin-top:0;}.notable-traits .notable-traits-tooltiptext{left:0;top:100%;}.help-button{display:none;}.search-container>div{width:calc(100% - 32px);}}@media print{nav.sub,.content .out-of-band,.collapse-toggle{display:none;}}@media (max-width:464px){#titles,#titles>button{height:73px;}#main,#search{margin-top:100px;}#main>table:not(.table-display) td{word-break:break-word;width:50%;}.search-container>div{display:block;width:calc(100% - 37px);}#crate-search{width:100%;border-radius:4px;border:0;}#crate-search+.search-input{width:calc(100% + 71px);margin-left:-36px;}#theme-picker,#settings-menu{padding:5px;width:31px;height:31px;}#theme-picker{margin-top:-2px;}#settings-menu{top:7px;}.docblock{margin-left:12px;}}h3.notable{margin:0;margin-bottom:13px;font-size:19px;}kbd{display:inline-block;padding:3px 5px;font:15px monospace;line-height:10px;vertical-align:middle;border:solid 1px;border-radius:3px;box-shadow:inset 0 -1px 0;cursor:default;}.hidden-by-impl-hider,.hidden-by-usual-hider{display:none !important;}#implementations-list>h3>span.in-band{width:100%;}.table-display{width:100%;border:0;border-collapse:collapse;border-spacing:0;font-size:16px;}.table-display tr td:first-child{padding-right:0;}.table-display tr td:last-child{float:right;}.table-display .out-of-band{position:relative;font-size:19px;display:block;}#implementors-list>.impl-items .table-display .out-of-band{font-size:17px;}.table-display td:hover .anchor{display:block;top:2px;left:-5px;}#main>ul{padding-left:10px;}#main>ul>li{list-style:none;}.non-exhaustive{margin-bottom:1em;}div.children{padding-left:27px;display:none;}div.name{cursor:pointer;position:relative;margin-left:16px;}div.files>a{display:block;padding:0 3px;}div.files>a:hover,div.name:hover{background-color:#a14b4b;}div.name.expand+.children{display:block;}div.name::before{content:"\25B6";padding-left:4px;font-size:0.7em;position:absolute;left:-16px;top:4px;}div.name.expand::before{transform:rotate(90deg);left:-15px;top:2px;}.type-decl>pre>.toggle-wrapper.toggle-attributes.top-attr{margin-left:0 !important;}.type-decl>pre>.docblock.attributes.top-attr{margin-left:1.8em !important;}.type-decl>pre>.toggle-attributes{margin-left:2.2em;}.type-decl>pre>.docblock.attributes{margin-left:4em;} \ No newline at end of file diff --git a/docs/doc/search-index.js b/docs/doc/search-index.js deleted file mode 100644 index 739a307..0000000 --- a/docs/doc/search-index.js +++ /dev/null @@ -1,4 +0,0 @@ -var searchIndex = JSON.parse('{\ -"ntext":{"doc":"","i":[[5,"to_text_no_seperator","ntext","Convert u32 to words in a string.",null,[[["u32",15]],["string",3]]],[5,"to_text_with_seperator","","Convert u32 to words in a string seperated by a seperator.",null,[[["u32",15],["str",15]],["string",3]]],[5,"digit_to_text","","Convert digit to words in a string.",null,[[["u8",15]],[["option",4],["string",3]]]],[14,"to_text","","Macro which supports both seperator and without it",null,null]],"p":[]}\ -}'); -addSearchOptions(searchIndex);initSearch(searchIndex); \ No newline at end of file diff --git a/docs/doc/settings.css b/docs/doc/settings.css deleted file mode 100644 index 6709865..0000000 --- a/docs/doc/settings.css +++ /dev/null @@ -1 +0,0 @@ -.setting-line{padding:5px;position:relative;}.setting-line>div{display:inline-block;vertical-align:top;font-size:17px;padding-top:2px;}.setting-line>.title{font-size:19px;width:100%;max-width:none;border-bottom:1px solid;}.toggle{position:relative;display:inline-block;width:45px;height:27px;margin-right:20px;}.toggle input{opacity:0;position:absolute;}.select-wrapper{float:right;position:relative;height:27px;min-width:25%;}.select-wrapper select{appearance:none;-moz-appearance:none;-webkit-appearance:none;background:none;border:2px solid #ccc;padding-right:28px;width:100%;}.select-wrapper img{pointer-events:none;position:absolute;right:0;bottom:0;background:#ccc;height:100%;width:28px;padding:0px 4px;}.select-wrapper select option{color:initial;}.slider{position:absolute;cursor:pointer;top:0;left:0;right:0;bottom:0;background-color:#ccc;-webkit-transition:.3s;transition:.3s;}.slider:before{position:absolute;content:"";height:19px;width:19px;left:4px;bottom:4px;background-color:white;-webkit-transition:.3s;transition:.3s;}input:checked+.slider{background-color:#2196F3;}input:focus+.slider{box-shadow:0 0 0 2px #0a84ff,0 0 0 6px rgba(10,132,255,0.3);}input:checked+.slider:before{-webkit-transform:translateX(19px);-ms-transform:translateX(19px);transform:translateX(19px);}.setting-line>.sub-settings{padding-left:42px;width:100%;display:block;} \ No newline at end of file diff --git a/docs/doc/settings.html b/docs/doc/settings.html deleted file mode 100644 index e0455ab..0000000 --- a/docs/doc/settings.html +++ /dev/null @@ -1,7 +0,0 @@ -1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -
-//!```rust -//!extern crate ntext; -//!use ntext::digit_to_text; -//!fn main() { -//! println!("{}",digit_to_text(1).unwrap()); -//! assert_eq!("two",digit_to_text(2).unwrap()); -//! assert_ne!("five",digit_to_text(8).unwrap()); -//!} -//!``` -//! However giving the program a zero will return an empty string. -//! -//!```rust -//!extern crate ntext; -//!use ntext::to_text; -//!fn main() { -//! println!("{}",to_text!(1312)); -//! assert_eq!(to_text!(1312),"onethousandthreehundredtwelve"); -//! println!("{}",to_text!(7123)); -//! assert_eq!(to_text!(7123," "),"seven thousand one hundred twenty three"); -//!} -//!``` -//! This macro will also return an empty string on input zero - -mod no_seperator; -mod seperator; -mod test; -pub use no_seperator::to_text_no_seperator; -pub use seperator::to_text_with_seperator; - -/// Convert digit to words in a string. -pub fn digit_to_text(digit: u8) -> Option<String> { - match digit { - 0 => Some("".to_string()), - 1 => Some("one".to_string()), - 2 => Some("two".to_string()), - 3 => Some("three".to_string()), - 4 => Some("four".to_string()), - 5 => Some("five".to_string()), - 6 => Some("six".to_string()), - 7 => Some("seven".to_string()), - 8 => Some("eight".to_string()), - 9 => Some("nine".to_string()), - _ => None, - } -} -fn place_value(number: u8, place: u8, seperator: Option<&str>) -> Option<String> { - let mut buffer = digit_to_text(number).unwrap(); - if let Some(sep) = seperator { - if number != 0 { - buffer.push_str(sep) - } - } - match place { - 1 => (), - 2 => (), //This should never happen as 2 is included in the tens_place_holders - 3 => buffer.push_str("hundred"), - 4 => buffer.push_str("thousand"), - 5 => (), // Souldn't happen - 6 => buffer.push_str("million"), - _ => (), - }; - Some(buffer) -} - -/// Macro which supports both seperator and without it -#[macro_export] -macro_rules! to_text { - ($number:expr) => { - ntext::to_text_no_seperator($number); - }; - ($number:expr, $seperator:expr) => { - ntext::to_text_with_seperator($number, $seperator); - }; -} -
1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -
-use crate::{digit_to_text, place_value}; -fn tens_place(tens: u8, ones: u8) -> Option<String> { - match tens { - 0 => digit_to_text(ones), - 1 => match ones { - 0 => Some("ten".to_string()), - 1 => Some("eleven".to_string()), - 2 => Some("twelve".to_string()), - 3 => Some("thirteen".to_string()), - 4 => Some("fourteen".to_string()), - 5 => Some("fifteen".to_string()), - 6 => Some("sixteen".to_string()), - 7 => Some("seventeen".to_string()), - 8 => Some("eighteen".to_string()), - 9 => Some("nineteen".to_string()), - _ => None, - }, - d @ 2..=5 | d @ 8 => Some({ - let mut buffer = String::new(); - match d { - 2 => buffer.push_str("twenty"), - 3 => buffer.push_str("thirty"), - 4 => buffer.push_str("forty"), - 5 => buffer.push_str("fifty"), - 8 => buffer.push_str("eighty"), - _ => (), - } - buffer.push_str(digit_to_text(ones).unwrap().as_str()); - buffer - }), - d @ 6..=9 => Some({ - let mut string = digit_to_text(d).unwrap() + "ty"; - string.push_str(digit_to_text(ones).unwrap().as_str()); - string - }), - _ => None, - } -} - -/// Convert u32 to words in a string. -pub fn to_text_no_seperator(number: u32) -> String { - let mut numtext: String = String::new(); - let mut last: Option<u8> = None; - let tens_place_holders: [u8; 2] = [2, 5]; - let digits: Vec<u8> = number - .to_string() - .chars() - .map(|d| d.to_digit(10).unwrap() as u8) - .collect(); - - let mut place: u8 = digits.len() as u8; - - for (_index, digit) in digits.iter().enumerate() { - if tens_place_holders.contains(&place) { - last = Some(*digit); - place -= 1; - continue; - } - if let Some(last_digit) = last { - numtext.push_str(tens_place(last_digit, *digit).unwrap().as_str()); - if place > 2 { - numtext.push_str(place_value(0, place, None).unwrap().as_str()); - } - last = None; - } else if *digit != 0 { - numtext.push_str(place_value(*digit, place, None).unwrap().as_str()) - } - place -= 1; - } - numtext -} -
1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -
-use crate::{digit_to_text, place_value}; - -fn tens_place_seperator(tens: u8, ones: u8, seperator: &str) -> Option<String> { - match tens { - 0 => digit_to_text(ones), - 1 => match ones { - 0 => Some("ten".to_string()), - 1 => Some("eleven".to_string()), - 2 => Some("twelve".to_string()), - 3 => Some("thirteen".to_string()), - 4 => Some("fourteen".to_string()), - 5 => Some("fifteen".to_string()), - 6 => Some("sixteen".to_string()), - 7 => Some("seventeen".to_string()), - 8 => Some("eighteen".to_string()), - 9 => Some("nineteen".to_string()), - _ => None, - }, - d @ 2..=5 | d @ 8 => Some({ - let mut buffer = String::new(); - match d { - 2 => buffer.push_str("twenty"), - 3 => buffer.push_str("thirty"), - 4 => buffer.push_str("forty"), - 5 => buffer.push_str("fifty"), - 8 => buffer.push_str("eighty"), - _ => (), - } - buffer.push_str(seperator); - buffer.push_str(digit_to_text(ones).unwrap().as_str()); - buffer - }), - d @ 6..=9 => Some({ - let mut buffer = digit_to_text(d).unwrap() + "ty"; - buffer.push_str(seperator); - buffer.push_str(digit_to_text(ones).unwrap().as_str()); - buffer - }), - _ => None, - } -} - -/// Convert u32 to words in a string seperated by a seperator. -pub fn to_text_with_seperator(number: u32, seperator: &str) -> String { - let mut numtext: String = String::new(); - let mut last: Option<u8> = None; - let tens_place_holders: [u8; 2] = [2, 5]; - let digits: Vec<u8> = number - .to_string() - .chars() - .map(|d| d.to_digit(10).unwrap() as u8) - .collect(); - - let mut place: u8 = digits.len() as u8; - - for (_index, digit) in digits.iter().enumerate() { - if tens_place_holders.contains(&place) { - last = Some(*digit); - place -= 1; - continue; - } - if *digit != 0 && place != digits.len() as u8 && numtext != "" { - numtext.push_str(seperator); - } - if let Some(last_digit) = last { - numtext.push_str( - tens_place_seperator(last_digit, *digit, seperator) - .unwrap() - .as_str(), - ); - if place > 2 { - numtext.push_str(seperator); - numtext.push_str(place_value(0, place, Some(seperator)).unwrap().as_str()); - } - last = None; - } else if *digit != 0 { - numtext.push_str( - place_value(*digit, place, Some(seperator)) - .unwrap() - .as_str(), - ); - } - place -= 1; - } - numtext -} -
1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -
-#[cfg(test)] -mod tests { - #[test] - fn digits() { - use crate::digit_to_text; - assert_eq!(digit_to_text(9).unwrap(), "nine"); - assert_eq!(digit_to_text(3).unwrap(), "three"); - assert_eq!(digit_to_text(7).unwrap(), "seven"); - assert_eq!(digit_to_text(5).unwrap(), "five"); - } - #[test] - fn numbers() { - use crate::to_text_no_seperator as to_text; - assert_eq!(to_text(1), "one"); - assert_eq!(to_text(10), "ten"); - assert_eq!(to_text(100), "onehundred"); - assert_eq!(to_text(1000), "onethousand"); - assert_eq!(to_text(12345), "twelvethousandthreehundredfortyfive"); - assert_eq!(to_text(81123), "eightyonethousandonehundredtwentythree"); - assert_eq!(to_text(12), "twelve"); - } - #[test] - fn numbers_seperator() { - use crate::to_text_with_seperator as to_text; - assert_eq!(to_text(103, "/"), "one/hundred/three"); - assert_eq!(to_text(1000, "/"), "one/thousand"); - assert_eq!( - to_text(12345, "/"), - "twelve/thousand/three/hundred/forty/five" - ); - assert_eq!( - to_text(651243, "/"), - "six/million/fifty/one/thousand/two/hundred/forty/three" - ); - } -} -
pub fn digit_to_text(digit: u8) -> Option<String>
pub fn digit_to_text(digit: u8) -> Option<String>
Convert digit to words in a string.
+extern crate ntext; use ntext::digit_to_text; @@ -25,7 +25,8 @@
| to_text | Macro which supports both seperator and without it |
| digit_to_text | |||||||
| to_text_no_seperator | Convert u32 to words in a string. +
Macro ntext:: |