file_name
large_stringlengths
4
69
prefix
large_stringlengths
0
26.7k
suffix
large_stringlengths
0
24.8k
middle
large_stringlengths
0
2.12k
fim_type
large_stringclasses
4 values
function-arguments.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
fn zzz() {()}
{ zzz(); (x, y) }
identifier_body
errors.rs
use super::ast::AstLocation; use tok::Tok; use tok::Location as TokenLocation; error_chain! { types { Error, ErrorKind, ResultExt, Result; } foreign_links { Io(::std::io::Error); Parse(::lalrpop_util::ParseError<TokenLocation, Tok, char>); } errors { TypeMismatch(e...
} }
display("Invalid import expression: {:?} at {}", node, location) }
random_line_split
main.rs
#![feature(slicing_syntax)] use std::io::{File,BufferedReader}; use std::num::SignedInt; // abs method use std::io::fs; fn filesize(size: int) -> String { let units = "KMGT"; let mut left = size.abs() as f64; let mut unit = -1i; while left > 1100. && unit < 3 { left /= 1024.; unit += 1; } if unit...
fn get_swap() -> Vec<(uint, int, String)> { fs::readdir(&Path::new("/proc")).unwrap().iter().filter_map( |d| d.filename_str().unwrap().parse().and_then(|pid| match get_swap_for(pid) { 0 => None, swap => Some((pid, swap, get_comm_for(pid))), } ) ).collect() } fn main() { // let...
{ let smaps_path = format!("/proc/{}/smaps", pid); let mut file = BufferedReader::new(File::open(&Path::new(smaps_path))); let mut s = 0; for l in file.lines() { let line = match l { Ok(s) => s, Err(_) => return 0, }; if line.starts_with("Swap:") { s += line.words().nth(1).unwrap(...
identifier_body
main.rs
#![feature(slicing_syntax)] use std::io::{File,BufferedReader}; use std::num::SignedInt; // abs method use std::io::fs; fn filesize(size: int) -> String { let units = "KMGT"; let mut left = size.abs() as f64; let mut unit = -1i; while left > 1100. && unit < 3 { left /= 1024.; unit += 1; } if unit...
(pid: uint) -> String { let cmdline_path = format!("/proc/{}/cmdline", pid); match File::open(&Path::new(&cmdline_path)).read_to_string() { // s may be empty for kernel threads Ok(s) => chop_null(s), Err(_) => String::new(), } } fn get_swap_for(pid: uint) -> int { let smaps_path = format!("/proc/{}...
get_comm_for
identifier_name
main.rs
#![feature(slicing_syntax)] use std::io::{File,BufferedReader}; use std::num::SignedInt; // abs method use std::io::fs; fn filesize(size: int) -> String { let units = "KMGT"; let mut left = size.abs() as f64; let mut unit = -1i;
while left > 1100. && unit < 3 { left /= 1024.; unit += 1; } if unit == -1 { format!("{}B", size) } else { if size < 0 { left = -left; } format!("{:.1}{}iB", left, units.char_at(unit as uint)) } } fn chop_null(s: String) -> String { let last = s.len() - 1; let mut s = s; ...
random_line_split
event.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::callback::ExceptionHandling; use crate::dom::bindings::cell::DomRefCell; use crate::dom:...
(bubbles: EventBubbles) -> Self { match bubbles { EventBubbles::Bubbles => true, EventBubbles::DoesNotBubble => false, } } } #[derive(Clone, Copy, MallocSizeOf, PartialEq)] pub enum EventCancelable { Cancelable, NotCancelable, } impl From<bool> for EventCancelable {...
from
identifier_name
event.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::callback::ExceptionHandling; use crate::dom::bindings::cell::DomRefCell; use crate::dom:...
pub fn new_uninitialized(global: &GlobalScope) -> DomRoot<Event> { reflect_dom_object(Box::new(Event::new_inherited()), global, EventBinding::Wrap) } pub fn new( global: &GlobalScope, type_: Atom, bubbles: EventBubbles, cancelable: EventCancelable, ) -> DomRoot...
{ Event { reflector_: Reflector::new(), current_target: Default::default(), target: Default::default(), type_: DomRefCell::new(atom!("")), phase: Cell::new(EventPhase::None), canceled: Cell::new(EventDefault::Allowed), stop_prop...
identifier_body
event.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::callback::ExceptionHandling; use crate::dom::bindings::cell::DomRefCell; use crate::dom:...
self.status() } pub fn status(&self) -> EventStatus { match self.DefaultPrevented() { true => EventStatus::Canceled, false => EventStatus::NotCanceled, } } #[inline] pub fn dispatching(&self) -> bool { self.dispatching.get() } #[inli...
// Step 10-12. self.clear_dispatching_flags(); // Step 14.
random_line_split
lib.rs
/* * Copyright 2015-2019 Ben Ashford * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agree...
/// /// This function is exposed to allow extensions to certain operations, it is /// not expected to be used by consumers of the library fn do_req(resp: reqwest::Response) -> Result<reqwest::Response, EsError> { let mut resp = resp; let status = resp.status(); match status { StatusCode::OK | Status...
random_line_split
lib.rs
/* * Copyright 2015-2019 Ben Ashford * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agree...
(client: &mut Client, index_name: &str) { // TODO - this should use the Bulk API let documents = vec![ TestDocument::new() .with_str_field("Document A123") .with_int_field(1), TestDocument::new() .with_str_field("Document B456") ...
setup_test_data
identifier_name
capability_list.rs
// Copyright (c) 2017 David Renshaw and contributors // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify...
fn get_from_pointer(builder: PointerBuilder<'a>, default: Option<&'a [crate::Word]>) -> Result<Builder<'a, T>> { Ok(Builder { marker: PhantomData, builder: builder.get_list(Pointer, default)? }) } } impl <'a, T> Builder<'a, T> where T: FromClientHook { pub fn get(se...
{ Builder { marker: PhantomData, builder: builder.init_list(Pointer, size), } }
identifier_body
capability_list.rs
// Copyright (c) 2017 David Renshaw and contributors // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify...
(reader: &PointerReader<'a>, default: Option<&'a [crate::Word]>) -> Result<Reader<'a, T>> { Ok(Reader { reader: reader.get_list(Pointer, default)?, marker: PhantomData }) } } impl <'a, T> Reader<'a, T> where T: FromClientHook { pub fn get(self, index: u32) -> Result<T> { ass...
get_from_pointer
identifier_name
capability_list.rs
// Copyright (c) 2017 David Renshaw and contributors // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify...
// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILI...
random_line_split
capsule.rs
/// existing traditional C ones, be it for gradual rewrites or to extend with new functionality. /// They can also be used for interaction between independently compiled Rust extensions if needed. /// /// Capsules can point to data, usually static arrays of constants and function pointers, /// or to function pointers ...
Ok(caps_ptr) } /// Convenience method to create a capsule for some data /// /// The encapsuled data may be an array of functions, but it can't be itself a /// function directly. /// /// May panic when running out of memory. /// pub fn new_data<T, N>(py: Python, data: &'stat...
{ return Err(PyErr::fetch(py)); }
conditional_block
capsule.rs
/// existing traditional C ones, be it for gradual rewrites or to extend with new functionality. /// They can also be used for interaction between independently compiled Rust extensions if needed. /// /// Capsules can point to data, usually static arrays of constants and function pointers, /// or to function pointers ...
/// Creates a new capsule from a raw void pointer /// /// This is suitable in particular to store a function pointer in a capsule. These /// can be obtained simply by a simple cast: /// /// ``` /// use libc::c_void; /// /// extern "C" fn inc(a: i32) -> i32 { /// a + 1 /...
{ Self::new(py, data as *const T as *const c_void, name) }
identifier_body
capsule.rs
/// existing traditional C ones, be it for gradual rewrites or to extend with new functionality. /// They can also be used for interaction between independently compiled Rust extensions if needed. /// /// Capsules can point to data, usually static arrays of constants and function pointers, /// or to function pointers ...
(py: Python, name: &CStr) -> PyResult<*const c_void> { let caps_ptr = unsafe { PyCapsule_Import(name.as_ptr(), 0) }; if caps_ptr.is_null() { return Err(PyErr::fetch(py)); } Ok(caps_ptr) } /// Convenience method to create a capsule for some data /// /// The en...
import
identifier_name
capsule.rs
besides /// existing traditional C ones, be it for gradual rewrites or to extend with new functionality. /// They can also be used for interaction between independently compiled Rust extensions if needed. /// /// Capsules can point to data, usually static arrays of constants and function pointers, /// or to function p...
/// Convenience method to create a capsule for some data /// /// The encapsuled data may be an array of functions, but it can't be itself a /// function directly. /// /// May panic when running out of memory. /// pub fn new_data<T, N>(py: Python, data: &'static T, name: N) -> Result<Sel...
Ok(caps_ptr) }
random_line_split
nul-characters.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let all_nuls1 = "\0\x00\u0000\U00000000"; let all_nuls2 = "\U00000000\u0000\x00\0"; let all_nuls3 = "\u0000\U00000000\x00\0"; let all_nuls4 = "\x00\u0000\0\U00000000"; // sizes for two should suffice assert_eq!(all_nuls1.len(), 4); assert_eq!(all_nuls2.len(), 4); // string equali...
main
identifier_name
nul-characters.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
assert_eq!(c1,c2); } } // testing equality between explicit character literals assert_eq!('\0', '\x00'); assert_eq!('\u0000', '\x00'); assert_eq!('\u0000', '\U00000000'); // NUL characters should make a difference assert!("Hello World"!= "Hello \0World"); assert...
{ let all_nuls1 = "\0\x00\u0000\U00000000"; let all_nuls2 = "\U00000000\u0000\x00\0"; let all_nuls3 = "\u0000\U00000000\x00\0"; let all_nuls4 = "\x00\u0000\0\U00000000"; // sizes for two should suffice assert_eq!(all_nuls1.len(), 4); assert_eq!(all_nuls2.len(), 4); // string equality ...
identifier_body
nul-characters.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
assert_eq!(c1,c2); } } // testing equality between explicit character literals assert_eq!('\0', '\x00'); assert_eq!('\u0000', '\x00'); assert_eq!('\u0000', '\U00000000'); // NUL characters should make a difference assert!("Hello World"!= "Hello \0World"); assert...
{ for c2 in all_nuls1.iter() {
random_line_split
hrtb-perfect-forwarding.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn main() { }
{ // OK -- now we have `T : for<'b> Bar&'b isize>`. foo_hrtb_bar_hrtb(&mut t); }
identifier_body
hrtb-perfect-forwarding.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn foo_hrtb_bar_not<'b,T>(mut t: T) where T : for<'a> Foo<&'a isize> + Bar<&'b isize> { // Not OK -- The forwarding impl for `Foo` requires that `Bar` also // be implemented. Thus to satisfy `&mut T : for<'a> Foo<&'a // isize>`, we require `T : for<'a> Bar<&'a isize>`, but the where // clause only ...
// example of a "perfect forwarding" impl. bar_hrtb(&mut t); }
random_line_split
hrtb-perfect-forwarding.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&mut self, x: X) { } } impl<'a,X,F> Foo<X> for &'a mut F where F : Foo<X> + Bar<X> { } impl<'a,X,F> Bar<X> for &'a mut F where F : Bar<X> { } fn no_hrtb<'b,T>(mut t: T) where T : Bar<&'b isize> { // OK -- `T : Bar<&'b isize>`, and thus the impl above ensures that // `&mut T : Bar<&'b isize>`. ...
bar
identifier_name
package.rs
use std::get_slice::GetSlice; use std::url::Url; use std::fs::File; use std::io::Read; use orbital::BmpFile; /// A package (_REDOX content serialized) pub struct
{ /// The URL pub url: Url, /// The ID of the package pub id: String, /// The name of the package pub name: String, /// The binary for the package pub binary: String, /// The icon for the package pub icon: BmpFile, /// The accepted extensions pub accepts: Vec<String>, ...
Package
identifier_name
package.rs
use std::get_slice::GetSlice; use std::url::Url; use std::fs::File; use std::io::Read; use orbital::BmpFile; /// A package (_REDOX content serialized) pub struct Package { /// The URL pub url: Url, /// The ID of the package pub id: String, /// The name of the package pub name: String, /// ...
} let mut info = String::new(); if let Ok(mut file) = File::open(&(url.to_string() + "_REDOX")) { file.read_to_string(&mut info); } for line in info.lines() { if line.starts_with("name=") { package.name = line.get_slice(Some(5), None).to...
for part in url.to_string().rsplit('/') { if !part.is_empty() { package.id = part.to_string(); break; }
random_line_split
package.rs
use std::get_slice::GetSlice; use std::url::Url; use std::fs::File; use std::io::Read; use orbital::BmpFile; /// A package (_REDOX content serialized) pub struct Package { /// The URL pub url: Url, /// The ID of the package pub id: String, /// The name of the package pub name: String, /// ...
else if line.starts_with("icon=") { package.icon = BmpFile::from_path(line.get_slice(Some(5), None)); } else if line.starts_with("accept=") { package.accepts.push(line.get_slice(Some(7), None).to_string()); } else if line.starts_with("author=") { ...
{ package.binary = url.to_string() + line.get_slice(Some(7), None); }
conditional_block
point-mutations.rs
extern crate point_mutations as dna; #[test] fn
() { assert_eq!(dna::hamming_distance("", "").unwrap(), 0); } #[test] #[ignore] fn test_no_difference_between_identical_strands() { assert_eq!(dna::hamming_distance("GGACTGA", "GGACTGA").unwrap(), 0); } #[test] #[ignore] fn test_complete_hamming_distance_in_small_strand() { assert_eq!(dna::hamming_distanc...
test_no_difference_between_empty_strands
identifier_name
point-mutations.rs
extern crate point_mutations as dna; #[test] fn test_no_difference_between_empty_strands() { assert_eq!(dna::hamming_distance("", "").unwrap(), 0); } #[test] #[ignore] fn test_no_difference_between_identical_strands() { assert_eq!(dna::hamming_distance("GGACTGA", "GGACTGA").unwrap(), 0); } #[test] #[ignore] ...
#[test] #[ignore] fn test_first_string_is_longer() { assert_eq!(dna::hamming_distance("AAA", "AA"), Result::Err("inputs of different length")); } #[test] #[ignore] fn test_second_string_is_longer() { assert_eq!(dna::hamming_distance("A", "AA"), Result::Err("inputs of different length")); }
fn test_larger_distance() { assert_eq!(dna::hamming_distance("ACCAGGG", "ACTATGG").unwrap(), 2); }
random_line_split
point-mutations.rs
extern crate point_mutations as dna; #[test] fn test_no_difference_between_empty_strands() { assert_eq!(dna::hamming_distance("", "").unwrap(), 0); } #[test] #[ignore] fn test_no_difference_between_identical_strands() { assert_eq!(dna::hamming_distance("GGACTGA", "GGACTGA").unwrap(), 0); } #[test] #[ignore] ...
#[test] #[ignore] fn test_larger_distance() { assert_eq!(dna::hamming_distance("ACCAGGG", "ACTATGG").unwrap(), 2); } #[test] #[ignore] fn test_first_string_is_longer() { assert_eq!(dna::hamming_distance("AAA", "AA"), Result::Err("inputs of different length")); } #[test] #[ignore] fn test_second_string_is_lo...
{ assert_eq!(dna::hamming_distance("GGACG", "GGTCG").unwrap(), 1); }
identifier_body
p048.rs
//! [Problem 48](https://projecteuler.net/problem=48) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results )] use num_bigint::BigUint; use num_traits::{FromPrimitive, ToPrimitive}; fn compute(max: u64, modulo: u64) -> u64 { ...
} common::problem!("9110846700", solve); #[cfg(test)] mod tests { #[test] fn ten() { let modulo = 100_0000_0000; assert_eq!(10405071317 % modulo, super::compute(10, modulo)) } }
random_line_split
p048.rs
//! [Problem 48](https://projecteuler.net/problem=48) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results )] use num_bigint::BigUint; use num_traits::{FromPrimitive, ToPrimitive}; fn compute(max: u64, modulo: u64) -> u64 { ...
() -> String { compute(1000, 100_0000_0000).to_string() } common::problem!("9110846700", solve); #[cfg(test)] mod tests { #[test] fn ten() { let modulo = 100_0000_0000; assert_eq!(10405071317 % modulo, super::compute(10, modulo)) } }
solve
identifier_name
p048.rs
//! [Problem 48](https://projecteuler.net/problem=48) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results )] use num_bigint::BigUint; use num_traits::{FromPrimitive, ToPrimitive}; fn compute(max: u64, modulo: u64) -> u64 { ...
common::problem!("9110846700", solve); #[cfg(test)] mod tests { #[test] fn ten() { let modulo = 100_0000_0000; assert_eq!(10405071317 % modulo, super::compute(10, modulo)) } }
{ compute(1000, 100_0000_0000).to_string() }
identifier_body
mod.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<T, F>(mut f: F) -> io::Result<T> where T: SignedInt, F: FnMut() -> T { loop { match cvt(f()) { Err(ref e) if e.kind() == ErrorKind::Interrupted => {} other => return other, } } } pub fn ms_to_timeval(ms: u64) -> libc::timeval { libc::timeval { tv_sec: (m...
cvt_r
identifier_name
mod.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn wouldblock() -> bool { let err = os::errno(); err == libc::EWOULDBLOCK as i32 || err == libc::EAGAIN as i32 } pub fn set_nonblocking(fd: sock_t, nb: bool) -> IoResult<()> { let set = nb as libc::c_int; mkerr_libc(retry(|| unsafe { c::ioctl(fd, c::FIONBIO, &set) })) } // nothing needed on unix...
{ libc::timeval { tv_sec: (ms / 1000) as libc::time_t, tv_usec: ((ms % 1000) * 1000) as libc::suseconds_t, } }
identifier_body
mod.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
}; ) } pub mod backtrace; pub mod c; pub mod condvar; pub mod ext; pub mod fd; pub mod fs; // support for std::old_io pub mod fs2; // support for std::fs pub mod helper_signal; pub mod mutex; pub mod net; pub mod os; pub mod os_str; pub mod pipe; pub mod process; pub mod rwlock; pub mod stack_overflow; pub mod sy...
cond: ::sync::CONDVAR_INIT, chan: ::cell::UnsafeCell { value: 0 as *mut Sender<$m> }, signal: ::cell::UnsafeCell { value: 0 }, initialized: ::cell::UnsafeCell { value: false }, shutdown: ::cell::UnsafeCell { value: false },
random_line_split
main.rs
#![feature(asm)] #![feature(const_fn)] #![feature(proc_macro)] #![no_std] extern crate cast; extern crate cortex_m; extern crate cortex_m_rtfm as rtfm; extern crate blue_pill; extern crate numtoa; use blue_pill::stm32f103xx::Interrupt; use cortex_m::peripheral::SystClkSource; use rtfm::{app, Threshold}; mod font5x7;...
p.RCC.apb1enr.modify(|_, w| w.i2c1en().enabled()); p.I2C1.cr1.write(|w| w.pe().clear_bit()); p.GPIOA.crl.modify(|_, w| w.mode6().input()); p.GPIOA.crh.modify(|_, w| { w.mode8().output50().cnf8().push().mode9().input() }); p.GPIOA.bsrr.write(|w| { w.bs6().set_bit().bs8().set_bi...
}); p.AFIO.mapr.modify(|_, w| unsafe { w.swj_cfg().bits(2).i2c1_remap().clear_bit() });
random_line_split
main.rs
#![feature(asm)] #![feature(const_fn)] #![feature(proc_macro)] #![no_std] extern crate cast; extern crate cortex_m; extern crate cortex_m_rtfm as rtfm; extern crate blue_pill; extern crate numtoa; use blue_pill::stm32f103xx::Interrupt; use cortex_m::peripheral::SystClkSource; use rtfm::{app, Threshold}; mod font5x7;...
(_t: &mut Threshold, r: EXTI0::Resources) { let i2c1 = &**r.I2C1; let oled = SSD1306(OLED_ADDR, &i2c1); let am = MMA8652FC(&i2c1); r.STATE.update_accel(am.accel()); r.STATE.update_state(); oled.print(0, 0, "X "); oled.print(8, 0, "Y "); oled.print(0, 1, "Z "); let accel = r.STATE....
update_ui
identifier_name
main.rs
#![feature(asm)] #![feature(const_fn)] #![feature(proc_macro)] #![no_std] extern crate cast; extern crate cortex_m; extern crate cortex_m_rtfm as rtfm; extern crate blue_pill; extern crate numtoa; use blue_pill::stm32f103xx::Interrupt; use cortex_m::peripheral::SystClkSource; use rtfm::{app, Threshold}; mod font5x7;...
; exti.pr.write(|w| w.pr6().set_bit()); // Button B } else if exti.pr.read().pr9().bit_is_set() { if gpioa.idr.read().idr9().bit_is_clear() { r.STATE.update_keys(Keys::B) } else { r.STATE.update_keys(Keys::None) }; exti.pr.write(|w| w.pr9().set_bit(...
{ r.STATE.update_keys(Keys::None); }
conditional_block
main.rs
#![feature(asm)] #![feature(const_fn)] #![feature(proc_macro)] #![no_std] extern crate cast; extern crate cortex_m; extern crate cortex_m_rtfm as rtfm; extern crate blue_pill; extern crate numtoa; use blue_pill::stm32f103xx::Interrupt; use cortex_m::peripheral::SystClkSource; use rtfm::{app, Threshold}; mod font5x7;...
p.RCC.apb1enr.modify(|_, w| w.i2c1en().enabled()); p.I2C1.cr1.write(|w| w.pe().clear_bit()); p.GPIOA.crl.modify(|_, w| w.mode6().input()); p.GPIOA.crh.modify(|_, w| { w.mode8().output50().cnf8().push().mode9().input() }); p.GPIOA.bsrr.write(|w| { w.bs6().set_bit().bs8().set_bi...
{ // 48Mhz p.FLASH.acr.modify( |_, w| w.prftbe().enabled().latency().one(), ); p.RCC.cfgr.modify(|_, w| unsafe { w.bits(0x0068840A) }); p.RCC.cr.modify( |_, w| w.pllon().set_bit().hsion().set_bit(), ); while p.RCC.cr.read().pllrdy().bit_is_clear() {} while p.RCC.cr.read(...
identifier_body
packet_kind.rs
/* Copyright © 2016 Zetok Zalbavar <zexavexxe@gmail.com> This file is part of Tox.
Tox is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License alon...
Tox is libre software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
random_line_split
packet_kind.rs
/* Copyright © 2016 Zetok Zalbavar <zexavexxe@gmail.com> This file is part of Tox. Tox is libre software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option...
{ /// [`Ping`](./struct.Ping.html) request number. PingReq = 0, /// [`Ping`](./struct.Ping.html) response number. PingResp = 1, /// [`GetNodes`](./struct.GetNodes.html) packet number. GetN = 2, /// [`SendNodes`](./struct.SendNodes.html) packet number. SendN = ...
acketKind
identifier_name
instr_subsd.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; use ::test::run_test; #[test] fn subsd_1() { run_test(&Instruction { mnemonic: Mnemonic::SUBSD, operand1: Some(Direct(XMM2...
{ run_test(&Instruction { mnemonic: Mnemonic::SUBSD, operand1: Some(Direct(XMM4)), operand2: Some(IndirectDisplaced(RBX, 212302300, Some(OperandSize::Qword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[242, 15, 92, 163, 220...
identifier_body
instr_subsd.rs
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; use ::test::run_test; #[test] fn subsd_1() { run_test(&Instruction { mnemonic: Mnemonic::SUBSD, operand1: Some(Direct(XMM2...
() { run_test(&Instruction { mnemonic: Mnemonic::SUBSD, operand1: Some(Direct(XMM4)), operand2: Some(IndirectDisplaced(RBX, 212302300, Some(OperandSize::Qword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[242, 15, 92, 163, ...
subsd_4
identifier_name
instr_subsd.rs
use ::RegScale::*; use ::test::run_test; #[test] fn subsd_1() { run_test(&Instruction { mnemonic: Mnemonic::SUBSD, operand1: Some(Direct(XMM2)), operand2: Some(Direct(XMM5)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[242, 15, 92...
use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*;
random_line_split
opeq.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let mut x: int = 1; x *= 2; debug!(x); assert_eq!(x, 2); x += 3; debug!(x); assert_eq!(x, 5); x *= x; debug!(x); assert_eq!(x, 25); x /= 5; debug!(x); assert_eq!(x, 5); }
identifier_body
opeq.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let mut x: int = 1; x *= 2; debug!(x); assert_eq!(x, 2); x += 3; debug!(x); assert_eq!(x, 5); x *= x; debug!(x); assert_eq!(x, 25); x /= 5; debug!(x); assert_eq!(x, 5); }
main
identifier_name
opeq.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
}
x /= 5; debug!(x); assert_eq!(x, 5);
random_line_split
dst-bad-coerce4.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn main() { // With a vec of isizes. let f1: &Fat<[isize]> = &Fat { ptr: [1, 2, 3] }; let f2: &Fat<[isize; 3]> = f1; //~^ ERROR mismatched types //~| expected type `&Fat<[isize; 3]>` //~| found type `&Fat<[isize]>` //~| expected array of 3 elements, found slice // Tuple with a vec o...
ptr: T }
random_line_split
dst-bad-coerce4.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { // With a vec of isizes. let f1: &Fat<[isize]> = &Fat { ptr: [1, 2, 3] }; let f2: &Fat<[isize; 3]> = f1; //~^ ERROR mismatched types //~| expected type `&Fat<[isize; 3]>` //~| found type `&Fat<[isize]>` //~| expected array of 3 elements, found slice // Tuple with a vec of isizes. ...
main
identifier_name
dst-bad-coerce4.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ // With a vec of isizes. let f1: &Fat<[isize]> = &Fat { ptr: [1, 2, 3] }; let f2: &Fat<[isize; 3]> = f1; //~^ ERROR mismatched types //~| expected type `&Fat<[isize; 3]>` //~| found type `&Fat<[isize]>` //~| expected array of 3 elements, found slice // Tuple with a vec of isizes. ...
identifier_body
mod.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ entry: CFGIndex, exit: CFGIndex, } impl CFG { pub fn new(tcx: &ty::ctxt, blk: &ast::Block) -> CFG { construct::construct(tcx, blk) } }
CFGIndices
identifier_name
mod.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
*/ #![allow(dead_code)] // still a WIP, #6298 use middle::graph; use middle::ty; use syntax::ast; use util::nodemap::NodeMap; mod construct; pub mod graphviz; pub struct CFG { pub exit_map: NodeMap<CFGIndex>, pub graph: CFGGraph, pub entry: CFGIndex, pub exit: CFGIndex, } pub struct CFGNodeData { ...
random_line_split
create_changeset.rs
impl CreateCopyInfo { pub fn new(path: MononokePath, parent_index: usize) -> Self { CreateCopyInfo { path, parent_index } } async fn resolve( self, parents: &Vec<ChangesetContext>, ) -> Result<(MPath, ChangesetId), MononokeError> { let parent_ctx = parents.get(self.pare...
.ok_or_else(|| { MononokeError::InvalidRequest(format!( "Parent {} does not exist", parent_id )) })?; Ok::<_, MononokeError>(parent_ctx) }) ...
{ let allowed_no_parents = self .config() .source_control_service .permit_commits_without_parents; let valid_parent_count = parents.len() == 1 || (parents.len() == 0 && allowed_no_parents); // Merge rules are not validated yet, so only a single parent is suppo...
identifier_body
create_changeset.rs
impl CreateCopyInfo { pub fn new(path: MononokePath, parent_index: usize) -> Self { CreateCopyInfo { path, parent_index } } async fn resolve( self, parents: &Vec<ChangesetContext>, ) -> Result<(MPath, ChangesetId), MononokeError> { let parent_ctx = parents.get(self.par...
let parent_ctxs: Vec<_> = parents .iter() .map(|parent_id| async move { let parent_ctx = self .changeset(ChangesetSpecifier::Bonsai(parent_id.clone())) .await? .ok_or_else(|| { MononokeError::I...
// Obtain contexts for each of the parents (which should exist).
random_line_split
create_changeset.rs
impl CreateCopyInfo { pub fn new(path: MononokePath, parent_index: usize) -> Self { CreateCopyInfo { path, parent_index } } async fn resolve( self, parents: &Vec<ChangesetContext>, ) -> Result<(MPath, ChangesetId), MononokeError> { let parent_ctx = parents.get(self.pare...
( &self, parents: Vec<ChangesetId>, author: String, author_date: DateTime<FixedOffset>, committer: Option<String>, committer_date: Option<DateTime<FixedOffset>>, message: String, extra: BTreeMap<String, Vec<u8>>, changes: BTreeMap<MononokePath, Cre...
create_changeset
identifier_name
generic-arg-mismatch-recover.rs
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { Foo::<'static,'static, ()>(&0); //~ ERROR wrong number of lifetime arguments //~^ ERROR mismatched types Bar::<'static,'static, ()>(&()); //~ ERROR wrong number of lifetime arguments //~^ ERROR wrong number of type arguments }
main
identifier_name
generic-arg-mismatch-recover.rs
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn main() { Foo::<'static,'static, ()>(&0); //~ ERROR wrong number of lifetime arguments //~^ ERROR mismatched types Bar::<'static,'static, ()>(&()); //~ ERROR wrong number of lifetime arguments //~^ ERROR wrong number of type arguments }
struct Bar<'a>(&'a ());
random_line_split
log_handler.rs
use chrono::{Local, NaiveDate}; use std::collections::HashMap; use std::fs::{create_dir_all, File, OpenOptions}; use std::io; use std::io::Write; use std::path::Path; use std::thread; use tokio::{runtime::Runtime, sync::mpsc::Receiver, task}; use super::log_messages::LogMessage; pub fn create_log_handler(log_dir: Str...
if let Err(error) = file.write_all(log_line.as_bytes()) { println!("Error writing log file: {:?}", error); break; } } println!("Logging disabled."); }) .await .unwra...
);
random_line_split
log_handler.rs
use chrono::{Local, NaiveDate}; use std::collections::HashMap; use std::fs::{create_dir_all, File, OpenOptions}; use std::io; use std::io::Write; use std::path::Path; use std::thread; use tokio::{runtime::Runtime, sync::mpsc::Receiver, task}; use super::log_messages::LogMessage; pub fn
(log_dir: String, mut log_rx: Receiver<Box<dyn LogMessage>>) { thread::spawn(move || { let rt = Runtime::new().unwrap(); let local = task::LocalSet::new(); local.block_on(&rt, async move { task::spawn_local(async move { let mut day = Local::today().naive_local(); ...
create_log_handler
identifier_name
log_handler.rs
use chrono::{Local, NaiveDate}; use std::collections::HashMap; use std::fs::{create_dir_all, File, OpenOptions}; use std::io; use std::io::Write; use std::path::Path; use std::thread; use tokio::{runtime::Runtime, sync::mpsc::Receiver, task}; use super::log_messages::LogMessage; pub fn create_log_handler(log_dir: Str...
} else { match create_log_file(&log_dir, log, &day) { Ok(file) => { log_files.insert(log.to_owned(), file); log_files.get(log).unwrap() } ...
{ thread::spawn(move || { let rt = Runtime::new().unwrap(); let local = task::LocalSet::new(); local.block_on(&rt, async move { task::spawn_local(async move { let mut day = Local::today().naive_local(); let mut log_files: HashMap<String, File> = Ha...
identifier_body
log_handler.rs
use chrono::{Local, NaiveDate}; use std::collections::HashMap; use std::fs::{create_dir_all, File, OpenOptions}; use std::io; use std::io::Write; use std::path::Path; use std::thread; use tokio::{runtime::Runtime, sync::mpsc::Receiver, task}; use super::log_messages::LogMessage; pub fn create_log_handler(log_dir: Str...
} }; let log_line = format!( "{} {}\n", now.format("%H:%M:%S%.3f"), log_message.get_message() ); if let Err(error) = file.write_all(log_line.a...
{ println!("Could not create log file: {:?}", error); break; }
conditional_block
var-captured-in-nested-closure.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
{ a: int, b: f64, c: uint } fn main() { let mut variable = 1; let constant = 2; let a_struct = Struct { a: -3, b: 4.5, c: 5 }; let struct_ref = &a_struct; let owned = box 6; let managed = @7; let closure = || { let closure_local = 8; ...
Struct
identifier_name
var-captured-in-nested-closure.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
}; zzz(); nested_closure(); }; closure(); } fn zzz() {()}
{ let mut variable = 1; let constant = 2; let a_struct = Struct { a: -3, b: 4.5, c: 5 }; let struct_ref = &a_struct; let owned = box 6; let managed = @7; let closure = || { let closure_local = 8; let nested_closure = || { zzz(); ...
identifier_body
var-captured-in-nested-closure.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
// gdb-command:rbreak zzz // gdb-command:run // gdb-command:finish // gdb-command:print variable // gdb-check:$1 = 1 // gdb-command:print constant // gdb-check:$2 = 2 // gdb-command:print a_struct // gdb-check:$3 = {a = -3, b = 4.5, c = 5} // gdb-command:print *struct_ref // gdb-check:$4 = {a = -3, b = 4.5, c = 5} // ...
// compile-flags:-g
random_line_split
str.rs
// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. use std::alloc::{OncePool}; #[test] fn debug_char() { let mut buf = [0; 30]; let mut buf = Vec::with_pool(On...
display_str() { let mut buf = [0; 30]; let mut buf = Vec::with_pool(OncePool::new(buf.as_mut())); write!(&mut buf, "{}", "aä日"); test!(&*buf == "aä日"); }
mut buf = [0; 30]; let mut buf = Vec::with_pool(OncePool::new(buf.as_mut())); write!(&mut buf, "{:?}", "aä日"); test!(&*buf == "\"a\\u{e4}\\u{65e5}\""); } #[test] fn
identifier_body
str.rs
// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. use std::alloc::{OncePool}; #[test] fn debug_char() { let mut buf = [0; 30]; let mut buf = Vec::with_pool(On...
mut buf = [0; 30]; let mut buf = Vec::with_pool(OncePool::new(buf.as_mut())); write!(&mut buf, "{}", "aä日"); test!(&*buf == "aä日"); }
) { let
identifier_name
str.rs
// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. use std::alloc::{OncePool};
#[test] fn debug_char() { let mut buf = [0; 30]; let mut buf = Vec::with_pool(OncePool::new(buf.as_mut())); write!(&mut buf, "{:?}", 'a'); write!(&mut buf, "{:?}", 'ä'); write!(&mut buf, "{:?}", '日'); test!(&*buf == "'a''\\u{e4}''\\u{65e5}'"); } #[test] fn display_char() { let mut buf = [0;...
random_line_split
header_chain.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
{ genesis_header: Bytes, // special-case the genesis. candidates: RwLock<BTreeMap<u64, Entry>>, headers: RwLock<HashMap<H256, Bytes>>, best_block: RwLock<BlockDescriptor>, cht_roots: Mutex<Vec<H256>>, } impl HeaderChain { /// Create a new header chain given this genesis block. pub fn new(genesis: &[u8]) -> Sel...
HeaderChain
identifier_name
header_chain.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
} #[test] fn reorganize() { let spec = Spec::new_test(); let genesis_header = spec.genesis_header(); let chain = HeaderChain::new(&::rlp::encode(&genesis_header)); let mut parent_hash = genesis_header.hash(); let mut rolling_timestamp = genesis_header.timestamp(); for i in 1..6 { let mut header = H...
assert!(chain.get_header(BlockId::Number(9000)).is_some()); assert!(chain.cht_root(2).is_some()); assert!(chain.cht_root(3).is_none());
random_line_split
general.rs
use std::fmt::Write; use eew::*; pub fn format_eew_full(eew: &EEW) -> String { let mut output = String::new(); write_unwrap!(&mut output, "[EEW: {} - {}]\n", eew.id, eew.number); write_unwrap!(&mut output, "issue_pattern: {:?}, source: {:?}, kind: {:?}, \ issued_at: {:?}, occurred_at: {:?}, status: {:?}\n",...
output }
{ write_unwrap!(&mut output, "epicenter_name: {}, epicenter: {:?}, \ depth: {:?}, magnitude: {:?}, maximum_intensity: {:?}, epicenter_accuracy: {:?}, \ depth_accuracy: {:?}, magnitude_accuracy: {:?}, epicenter_category: {:?}, \ warning_status: {:?}, intensity_change: {:?}, change_reason: {:?}\n", detail....
conditional_block
general.rs
use std::fmt::Write; use eew::*; pub fn
(eew: &EEW) -> String { let mut output = String::new(); write_unwrap!(&mut output, "[EEW: {} - {}]\n", eew.id, eew.number); write_unwrap!(&mut output, "issue_pattern: {:?}, source: {:?}, kind: {:?}, \ issued_at: {:?}, occurred_at: {:?}, status: {:?}\n", eew.issue_pattern, eew.source, eew.kind, eew.issued_at, e...
format_eew_full
identifier_name
general.rs
use std::fmt::Write; use eew::*; pub fn format_eew_full(eew: &EEW) -> String
for area in detail.area_info.iter() { write_unwrap!(&mut output, "area_name: {}, minimum_intensity: {:?}, \ maximum_intensity: {:?}, reach_at: {:?}, warning_status: {:?}, wave_status: {:?}\n", area.area_name, area.minimum_intensity, area.maximum_intensity, area.reach_at, area.warning_status, area.wave_...
{ let mut output = String::new(); write_unwrap!(&mut output, "[EEW: {} - {}]\n", eew.id, eew.number); write_unwrap!(&mut output, "issue_pattern: {:?}, source: {:?}, kind: {:?}, \ issued_at: {:?}, occurred_at: {:?}, status: {:?}\n", eew.issue_pattern, eew.source, eew.kind, eew.issued_at, eew.occurred_at, eew.st...
identifier_body
general.rs
use std::fmt::Write; use eew::*; pub fn format_eew_full(eew: &EEW) -> String { let mut output = String::new(); write_unwrap!(&mut output, "[EEW: {} - {}]\n", eew.id, eew.number); write_unwrap!(&mut output, "issue_pattern: {:?}, source: {:?}, kind: {:?}, \ issued_at: {:?}, occurred_at: {:?}, status: {:?}\n",...
detail.epicenter_name, detail.epicenter, detail.depth, detail.magnitude, detail.maximum_intensity, detail.epicenter_accuracy, detail.depth_accuracy, detail.magnitude_accuracy, detail.epicenter_category, detail.warning_status, detail.intensity_change, detail.change_reason); for area in detail.area_info.it...
depth: {:?}, magnitude: {:?}, maximum_intensity: {:?}, epicenter_accuracy: {:?}, \ depth_accuracy: {:?}, magnitude_accuracy: {:?}, epicenter_category: {:?}, \ warning_status: {:?}, intensity_change: {:?}, change_reason: {:?}\n",
random_line_split
main.rs
use std::io; use std::rand; use std::cmp::Ordering; fn main() { let secret_number = (rand::random::<u32>() % 100) + 1; println!("Guess the number!"); loop { println!("Please input your guess."); let input = io::stdin().read_line() .ok() .expect("Faile...
{ if a < b { Ordering::Less } else if a > b { Ordering::Greater } else { Ordering::Equal } }
identifier_body
main.rs
use std::io; use std::rand; use std::cmp::Ordering; fn main() { let secret_number = (rand::random::<u32>() % 100) + 1; println!("Guess the number!"); loop { println!("Please input your guess."); let input = io::stdin().read_line() .ok() .expect("Faile...
}; println!("You guessed: {}", num); match cmp(num, secret_number) { Ordering::Less => println!("Too small!"), Ordering::Greater => println!("Too big!"), Ordering::Equal => { println!("You win!"); return; } } } } fn cmp(a: u32, b: u32) -> Ordering { if a < ...
println!("Please input a number!"); continue; }
random_line_split
main.rs
use std::io; use std::rand; use std::cmp::Ordering; fn
() { let secret_number = (rand::random::<u32>() % 100) + 1; println!("Guess the number!"); loop { println!("Please input your guess."); let input = io::stdin().read_line() .ok() .expect("Failed to read line"); let input_num: Option<u32> = input.tr...
main
identifier_name
manager.rs
/*use std::io::Write; use dbus::{BusType, Connection, ConnectionItem, Error, Message, MessageItem, NameFlag}; use dbus::obj::{Argument, Interface, Method, ObjectPath, Property}; use constants::*; pub struct Manager { running: bool, } impl Manager { pub fn new() -> Manager { Manager { running: false ...
vec![], vec![Argument::new("reply", "s")], Box::new(|msg| { Ok(vec!(MessageItem::Str(for...
let root_iface = Interface::new(vec![Method::new("Hello",
random_line_split
math.rs
use Vec3; use cgmath::Vector2; use cgmath::InnerSpace; use cgmath::dot; use std; #[derive(Eq, PartialEq, Copy, Clone, Debug, Hash)] pub struct Rect<F> { pub min : Vector2<F>, pub max : Vector2<F>, } pub type RectI = Rect<i32>; #[derive(PartialEq, Debug, Copy, Clone)] pub struct LineSegment { pub from:...
} } #[derive(PartialEq, Debug, Copy, Clone)] pub struct Plane { pub normal: Vec3, pub coefficient: f64, } impl Plane { pub fn from_origin_normal(origin:Vec3, normal:Vec3) -> Plane { Plane { normal:normal, coefficient: (normal.x * origin.x + normal.y * origin.y + normal...
{ Some((direction * ratio) + self.from) }
conditional_block
math.rs
use Vec3; use cgmath::Vector2; use cgmath::InnerSpace; use cgmath::dot; use std; #[derive(Eq, PartialEq, Copy, Clone, Debug, Hash)] pub struct Rect<F> { pub min : Vector2<F>, pub max : Vector2<F>, } pub type RectI = Rect<i32>; #[derive(PartialEq, Debug, Copy, Clone)] pub struct LineSegment { pub from: ...
#[derive(PartialEq, Debug, Copy, Clone)] pub struct Plane { pub normal: Vec3, pub coefficient: f64, } impl Plane { pub fn from_origin_normal(origin:Vec3, normal:Vec3) -> Plane { Plane { normal:normal, coefficient: (normal.x * origin.x + normal.y * origin.y + normal.z * orig...
} else { Some((direction * ratio) + self.from) } } }
random_line_split
math.rs
use Vec3; use cgmath::Vector2; use cgmath::InnerSpace; use cgmath::dot; use std; #[derive(Eq, PartialEq, Copy, Clone, Debug, Hash)] pub struct Rect<F> { pub min : Vector2<F>, pub max : Vector2<F>, } pub type RectI = Rect<i32>; #[derive(PartialEq, Debug, Copy, Clone)] pub struct LineSegment { pub from:...
(&self, plane:Plane) -> Option<Vec3> { let direction = (self.to - self.from).normalize(); let denominator = dot(plane.normal, direction); if denominator > -EPSILON && denominator < EPSILON { return None } let numerator = -(dot(plane.normal, self.from) - plane.coeffic...
intersects
identifier_name
uint_macros.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
#![macro_escape] #![doc(hidden)] macro_rules! uint_module (($T:ty, $T_SIGNED:ty, $bits:expr) => ( #[unstable] pub static BITS : uint = $bits; #[unstable] pub static BYTES : uint = ($bits / 8); #[unstable] pub static MIN: $T = 0 as $T; #[unstable] pub static MAX: $T = 0 as $T - 1 as $T; ))
// option. This file may not be copied, modified, or distributed // except according to those terms.
random_line_split
text.rs
use std::{env, process}; use yaml_rust::YamlLoader; #[allow(dead_code)] pub enum Errors { GtkInitError, ScreenshotUnsuccessful, StrfTimeUnavailable, PicturesFolderUnavailable, ScreenshotSaveError, ImageViewerError, FileError, ImgurUploadFailure, ClipboardUnavailable, MastodonIma...
{ let locators = YamlLoader::load_from_str(&loader()).unwrap(); let locator = &locators[0]["Error"]; let error = &locator["Error"].as_str().unwrap(); match code { 1..=31 => return format!("{} {}: {}", error, code, &locator[code].as_str().unwrap()), _ => unreachable!("Internal Logic Erro...
identifier_body
text.rs
use std::{env, process}; use yaml_rust::YamlLoader; #[allow(dead_code)] pub enum
{ GtkInitError, ScreenshotUnsuccessful, StrfTimeUnavailable, PicturesFolderUnavailable, ScreenshotSaveError, ImageViewerError, FileError, ImgurUploadFailure, ClipboardUnavailable, MastodonImageUnsuccessful, MastodonTootUnsuccessful, MastodonLoginError, TwitterImageUn...
Errors
identifier_name
text.rs
use std::{env, process}; use yaml_rust::YamlLoader; #[allow(dead_code)] pub enum Errors { GtkInitError, ScreenshotUnsuccessful, StrfTimeUnavailable, PicturesFolderUnavailable, ScreenshotSaveError, ImageViewerError, FileError, ImgurUploadFailure, ClipboardUnavailable, MastodonIma...
} else if lang.contains("de") { return include_str!("../lang/de.yml").to_string(); } else if lang.contains("pl") { return include_str!("../lang/pl.yml").to_string(); } else if lang.contains("pt") { return include_str!("../lang/pt.yml").to_string(); } else if lang.contains("sv") {...
random_line_split
string_expressions.rs
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
(args: &[ArrayRef]) -> Result<StringArray> { // downcast all arguments to strings let args = downcast_vec!(args, StringArray).collect::<Result<Vec<&StringArray>>>()?; // do not accept 0 arguments. if args.len() == 0 { return Err(DataFusionError::Internal( "Concatenate was called with...
concatenate
identifier_name
string_expressions.rs
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
} Ok(builder.finish()) }
{ builder.append_value(&owned_string)?; }
conditional_block
string_expressions.rs
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
is_null = true; break; // short-circuit as we already know the result } else { owned_string.push_str(&arg.value(index)); } } if is_null { builder.append_null()?; } else { builder.append_value(&owned_s...
{ // downcast all arguments to strings let args = downcast_vec!(args, StringArray).collect::<Result<Vec<&StringArray>>>()?; // do not accept 0 arguments. if args.len() == 0 { return Err(DataFusionError::Internal( "Concatenate was called with 0 arguments. It requires at least one." ...
identifier_body
string_expressions.rs
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
if arg.is_null(index) { is_null = true; break; // short-circuit as we already know the result } else { owned_string.push_str(&arg.value(index)); } } if is_null { builder.append_null()?; } else { ...
// if any is null, the result is null let mut is_null = false; for arg in &args {
random_line_split
borrowed-unique-basic.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
{()}
identifier_body
borrowed-unique-basic.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
// gdb-command:print *f32_ref // gdb-check:$13 = 2.5 // gdb-command:print *f64_ref // gdb-check:$14 = 3.5 // === LLDB TESTS ================================================================================== // lldb-command:type format add -f decimal char // lldb-command:type format add -f decimal 'unsigned char' /...
// gdb-command:print *u64_ref // gdb-check:$12 = 64
random_line_split
borrowed-unique-basic.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
() {()}
zzz
identifier_name
circd.rs
/////////////////////////////////////////////////////////////////////////////// #![feature(phase)] extern crate circ_comms; extern crate irc; #[phase(plugin, link)] extern crate log; extern crate time; /////////////////////////////////////////////////////////////////////////////// use irc::data::config::Config; use s...
() { let config = process_args(); let connection = connection::Connection::new(config); let socket = Path::new(circ_comms::address()); if socket.exists() { match fs::unlink(&socket) { Ok(_) => (), Err(e) => panic!("Unable to remove {}: {}", circ_comms::...
main
identifier_name
circd.rs
/////////////////////////////////////////////////////////////////////////////// #![feature(phase)] extern crate circ_comms; extern crate irc; #[phase(plugin, link)] extern crate log; extern crate time; /////////////////////////////////////////////////////////////////////////////// use irc::data::config::Config; use s...
Config::load(filename).unwrap() }, _ => panic!("Configuration file must be specified") } } /////////////////////////////////////////////////////////////////////////////// fn main() { let config = process_args(); let connection = connection::Connection::new(config); le...
panic!("File {} doesn't exist", arg); }
random_line_split
circd.rs
/////////////////////////////////////////////////////////////////////////////// #![feature(phase)] extern crate circ_comms; extern crate irc; #[phase(plugin, link)] extern crate log; extern crate time; /////////////////////////////////////////////////////////////////////////////// use irc::data::config::Config; use s...
/////////////////////////////////////////////////////////////////////////////// fn main() { let config = process_args(); let connection = connection::Connection::new(config); let socket = Path::new(circ_comms::address()); if socket.exists() { match fs::unlink(&socket) { ...
{ match os::args().tail() { [ref arg] => { let filename = Path::new(arg.as_slice()); if !filename.exists() { panic!("File {} doesn't exist", arg); } Config::load(filename).unwrap() }, _ => p...
identifier_body
image_decoder_d.rs
/*! A application that uses the `image-decoder` feature to load resources and display them. Requires the following features: `cargo run --example image_decoder_d --features "image-decoder file-dialog"` */ extern crate native_windows_gui as nwg; extern crate native_windows_derive as nwd; use nwd::NwgUi; use ...
{ nwg::init().expect("Failed to init Native Windows GUI"); nwg::Font::set_global_family("Segoe UI").expect("Failed to set default font"); let _app = ImageDecoderApp::build_ui(Default::default()).expect("Failed to build UI"); nwg::dispatch_thread_events(); }
identifier_body
image_decoder_d.rs
/*! A application that uses the `image-decoder` feature to load resources and display them. Requires the following features: `cargo run --example image_decoder_d --features "image-decoder file-dialog"` */ extern crate native_windows_gui as nwg; extern crate native_windows_derive as nwd; use nwd::NwgUi; use ...
if let Ok(directory) = self.dialog.get_selected_item() { let dir = directory.into_string().unwrap(); self.file_name.set_text(&dir); self.read_file(); } } } fn read_file(&self) { println!("{}", self.file_name.text()); ...
} } if self.dialog.run(Some(&self.window)) { self.file_name.set_text("");
random_line_split
image_decoder_d.rs
/*! A application that uses the `image-decoder` feature to load resources and display them. Requires the following features: `cargo run --example image_decoder_d --features "image-decoder file-dialog"` */ extern crate native_windows_gui as nwg; extern crate native_windows_derive as nwd; use nwd::NwgUi; use ...
() { nwg::init().expect("Failed to init Native Windows GUI"); nwg::Font::set_global_family("Segoe UI").expect("Failed to set default font"); let _app = ImageDecoderApp::build_ui(Default::default()).expect("Failed to build UI"); nwg::dispatch_thread_events(); }
main
identifier_name
htmldatalistelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLDataListElementBinding; use dom::bindings::codegen::Bindings::HTMLDataLi...
} let node = NodeCast::from_ref(self); let filter = box HTMLDataListOptionsFilter; let window = window_from_node(node); HTMLCollection::create(window.r(), node, filter) } }
{ elem.is_htmloptionelement() }
identifier_body
htmldatalistelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLDataListElementBinding; use dom::bindings::codegen::Bindings::HTMLDataLi...
} } impl HTMLDataListElementMethods for HTMLDataListElement { // https://html.spec.whatwg.org/multipage/#dom-datalist-options fn Options(&self) -> Root<HTMLCollection> { #[derive(JSTraceable, HeapSizeOf)] struct HTMLDataListOptionsFilter; impl CollectionFilter for HTMLDataListOption...
let element = HTMLDataListElement::new_inherited(localName, prefix, document); Node::reflect_node(box element, document, HTMLDataListElementBinding::Wrap)
random_line_split
htmldatalistelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLDataListElementBinding; use dom::bindings::codegen::Bindings::HTMLDataLi...
(localName: DOMString, prefix: Option<DOMString>, document: &Document) -> Root<HTMLDataListElement> { let element = HTMLDataListElement::new_inherited(localName, prefix, document); Node::reflect_node(box element, document, HTMLDataListElementBinding::Wrap) } } impl HTM...
new
identifier_name