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
timer.rs
use crate::sys; use libc::c_void; use std::marker::PhantomData; use std::mem; use crate::TimerSubsystem; impl TimerSubsystem { /// Constructs a new timer using the boxed closure `callback`. /// /// The timer is started immediately, it will be cancelled either: /// /// * when the timer is dropped ...
}), ); // tick the timer at least 10 times w/ 200ms of "buffer" ::std::thread::sleep(Duration::from_millis(250)); let num = local_num.lock().unwrap(); // read the number back assert_eq!(*num, 9); // it should have incremented at least 10 times... } fn test_...
{ 0 }
conditional_block
timer.rs
use crate::sys; use libc::c_void; use std::marker::PhantomData; use std::mem; use crate::TimerSubsystem; impl TimerSubsystem { /// Constructs a new timer using the boxed closure `callback`. /// /// The timer is started immediately, it will be cancelled either: /// /// * when the timer is dropped ...
(&self) -> u64 { unsafe { sys::SDL_GetPerformanceCounter() } } #[doc(alias = "SDL_GetPerformanceFrequency")] pub fn performance_frequency(&self) -> u64 { unsafe { sys::SDL_GetPerformanceFrequency() } } } pub type TimerCallback<'a> = Box<dyn FnMut() -> u32 + 'a + Sync>; pub struct Time...
performance_counter
identifier_name
timer.rs
use crate::sys; use libc::c_void; use std::marker::PhantomData; use std::mem; use crate::TimerSubsystem; impl TimerSubsystem { /// Constructs a new timer using the boxed closure `callback`. /// /// The timer is started immediately, it will be cancelled either: /// /// * when the timer is dropped ...
fn test_timer_runs_multiple_times() { let sdl_context = crate::sdl::init().unwrap(); let timer_subsystem = sdl_context.timer().unwrap(); let local_num = Arc::new(Mutex::new(0)); let timer_num = local_num.clone(); let _timer = timer_subsystem.add_timer( 20, ...
{ test_timer_runs_multiple_times(); test_timer_runs_at_least_once(); test_timer_can_be_recreated(); }
identifier_body
extra.rs
// Copyright 2012-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-MI...
pub mod bitv; pub mod deque; pub mod fun_treemap; pub mod list; pub mod priority_queue; pub mod smallintmap; pub mod sort; pub mod dlist; pub mod treemap; // Crypto #[path="crypto/digest.rs"] pub mod digest; #[path="crypto/sha1.rs"] pub mod sha1; #[path="crypto/sha2.rs"] pub mod sha2; // And... other stuff pub mo...
pub mod flatpipes; // Collections
random_line_split
riscv64-lp64-lp64f-lp64d-abi.rs
// // compile-flags: -C no-prepopulate-passes // only-riscv64 // only-linux #![crate_type = "lib"] #![allow(improper_ctypes)] // CHECK: define void @f_void() #[no_mangle] pub extern "C" fn f_void() {} // CHECK: define zeroext i1 @f_scalar_0(i1 zeroext %a) #[no_mangle] pub extern "C" fn f_scalar_0(a: bool) -> bool { ...
// CHECK: define signext i32 @f_scalar_3(i32 signext %x) #[no_mangle] pub extern "C" fn f_scalar_3(x: i32) -> u32 { x as u32 } // CHECK: define i64 @f_scalar_4(i64 %x) #[no_mangle] pub extern "C" fn f_scalar_4(x: i64) -> i64 { x } // CHECK: define float @f_fp_scalar_1(float %0) #[no_mangle] pub extern "C" f...
{ x }
identifier_body
riscv64-lp64-lp64f-lp64d-abi.rs
// // compile-flags: -C no-prepopulate-passes // only-riscv64 // only-linux #![crate_type = "lib"] #![allow(improper_ctypes)] // CHECK: define void @f_void() #[no_mangle] pub extern "C" fn f_void() {} // CHECK: define zeroext i1 @f_scalar_0(i1 zeroext %a) #[no_mangle] pub extern "C" fn f_scalar_0(a: bool) -> bool { ...
// CHECK: define zeroext i8 @f_scalar_2(i8 zeroext %x) #[no_mangle] pub extern "C" fn f_scalar_2(x: u8) -> u8 { x } // CHECK: define signext i32 @f_scalar_3(i32 signext %x) #[no_mangle] pub extern "C" fn f_scalar_3(x: i32) -> u32 { x as u32 } // CHECK: define i64 @f_scalar_4(i64 %x) #[no_mangle] pub extern "C...
pub extern "C" fn f_scalar_1(x: i8) -> i8 { x }
random_line_split
riscv64-lp64-lp64f-lp64d-abi.rs
// // compile-flags: -C no-prepopulate-passes // only-riscv64 // only-linux #![crate_type = "lib"] #![allow(improper_ctypes)] // CHECK: define void @f_void() #[no_mangle] pub extern "C" fn
() {} // CHECK: define zeroext i1 @f_scalar_0(i1 zeroext %a) #[no_mangle] pub extern "C" fn f_scalar_0(a: bool) -> bool { a } // CHECK: define signext i8 @f_scalar_1(i8 signext %x) #[no_mangle] pub extern "C" fn f_scalar_1(x: i8) -> i8 { x } // CHECK: define zeroext i8 @f_scalar_2(i8 zeroext %x) #[no_mangle]...
f_void
identifier_name
utf8.rs
// Copyright 2021 Luis Cáceres // // 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 agreed to i...
pub fn reset_from_utf8(&mut self) { self.utf8.reset_to_uchars(); self.converter.reset_from_uchars(); self.pivot_from_source = self.pivot_from.start; self.pivot_from_target = self.pivot_from_target; } pub fn feed_to_utf8(&mut self, dst: &mut [u8], src: &[u8]) -> FeedResult {...
self.converter.reset_to_uchars(); self.utf8.reset_from_uchars(); self.pivot_to_source = self.pivot_to.start; self.pivot_to_target = self.pivot_to_target; }
identifier_body
utf8.rs
// Copyright 2021 Luis Cáceres // // 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 agreed to i...
Ok(_) | Err(common::Error::Sys(sys::UErrorCode::U_BUFFER_OVERFLOW_ERROR)) => { dst = dst.split_at_mut(res.dst_consumed).1; src = src.split_at(res.src_consumed).1; } _ => panic!("conversion error"), } if dst....
let res = converter.feed_from_utf8(dst, src); match res.result {
random_line_split
utf8.rs
// Copyright 2021 Luis Cáceres // // 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 agreed to i...
&mut self) { self.reset_to_utf8(); self.reset_from_utf8(); } pub fn reset_to_utf8(&mut self) { self.converter.reset_to_uchars(); self.utf8.reset_from_uchars(); self.pivot_to_source = self.pivot_to.start; self.pivot_to_target = self.pivot_to_target; } pub...
eset(
identifier_name
special_functions.rs
use crate::analysis::{ functions::{Info as FuncInfo, Visibility}, imports::Imports, }; use std::{collections::BTreeMap, str::FromStr}; #[derive(Clone, Copy, Eq, Debug, Ord, PartialEq, PartialOrd)] pub enum Type { Compare, Copy, Equal, Free, Ref, ToString, Unref, Hash, } impl Fr...
(specials: &Infos, imports: &mut Imports) { use self::Type::*; for type_ in specials.keys() { match *type_ { Compare => imports.add("std::cmp"), ToString => imports.add("std::fmt"), Hash => imports.add("std::hash"), _ => {} } } }
analyze_imports
identifier_name
special_functions.rs
use crate::analysis::{ functions::{Info as FuncInfo, Visibility}, imports::Imports, }; use std::{collections::BTreeMap, str::FromStr}; #[derive(Clone, Copy, Eq, Debug, Ord, PartialEq, PartialOrd)] pub enum Type { Compare, Copy, Equal, Free, Ref, ToString, Unref, Hash, } impl Fr...
pub fn unhide(functions: &mut Vec<FuncInfo>, specials: &Infos, type_: Type) { if let Some(func) = specials.get(&type_) { let func = functions .iter_mut() .find(|f| f.glib_name == *func && f.visibility!= Visibility::Comment); if let Some(func) = func { func.visibilit...
} // Some special functions (e.g. `copy` on refcounted types) should be exposed
random_line_split
special_functions.rs
use crate::analysis::{ functions::{Info as FuncInfo, Visibility}, imports::Imports, }; use std::{collections::BTreeMap, str::FromStr}; #[derive(Clone, Copy, Eq, Debug, Ord, PartialEq, PartialOrd)] pub enum Type { Compare, Copy, Equal, Free, Ref, ToString, Unref, Hash, } impl Fr...
} pub type Infos = BTreeMap<Type, String>; // Type => glib_name fn update_func(func: &mut FuncInfo, type_: Type) -> bool { if func.visibility!= Visibility::Comment { func.visibility = visibility(type_, func.parameters.c_parameters.len()); } // I assume `to_string` functions never return `NULL` ...
{ use self::Type::*; match s { "compare" => Ok(Compare), "copy" => Ok(Copy), "equal" => Ok(Equal), "free" | "destroy" => Ok(Free), "is_equal" => Ok(Equal), "ref" | "ref_" => Ok(Ref), "to_string" => Ok(ToString), ...
identifier_body
event_notification.rs
use chrono::{offset::Utc, DateTime}; use diesel::{self, pg::PgConnection}; use schema::event_notifications; use timer::{event::Event, Timer}; #[derive(Debug, Identifiable, Queryable, QueryableByName)] #[table_name = "event_notifications"] pub struct EventNotification { id: i32, event_id: i32, // foreign key t...
() { with_connection(|conn| { with_timer(conn, |t1| { with_timer(conn, |t2| { with_timer(conn, |t3| { let (start, end) = if t1.fire_time() < t2.fire_time() { (t1, t2) } else { ...
create_event
identifier_name
event_notification.rs
use chrono::{offset::Utc, DateTime}; use diesel::{self, pg::PgConnection}; use schema::event_notifications; use timer::{event::Event, Timer}; #[derive(Debug, Identifiable, Queryable, QueryableByName)] #[table_name = "event_notifications"] pub struct EventNotification { id: i32, event_id: i32, // foreign key t...
.values(&self) .get_result(conn) } /// TODO: Maybe fail if notification is scheduled after event starts pub fn new(event: &Event, timer: &Timer) -> Self { NewEventNotification { event_id: event.id(), timer_id: timer.id(), } } } #[cfg(test)]...
random_line_split
event_notification.rs
use chrono::{offset::Utc, DateTime}; use diesel::{self, pg::PgConnection}; use schema::event_notifications; use timer::{event::Event, Timer}; #[derive(Debug, Identifiable, Queryable, QueryableByName)] #[table_name = "event_notifications"] pub struct EventNotification { id: i32, event_id: i32, // foreign key t...
; let (notif, start, end) = if t3.fire_time() < start.fire_time() { (t3, start, end) } else if t3.fire_time() < end.fire_time() { (start, t3, end) } else { (start,...
{ (t2, t1) }
conditional_block
cursor.rs
use super::result::PgResult; use super::row::PgRow; /// The type returned by various [`Connection`] methods. /// Acts as an iterator over `T`. pub struct Cursor<'a> { current_row: usize, db_result: &'a PgResult, } impl<'a> Cursor<'a> { pub(super) fn new(db_result: &'a PgResult) -> Self { Cursor { ...
} impl<'a> Iterator for Cursor<'a> { type Item = PgRow<'a>; fn next(&mut self) -> Option<Self::Item> { if self.current_row < self.db_result.num_rows() { let row = self.db_result.get_row(self.current_row); self.current_row += 1; Some(row) } else { ...
{ self.db_result.num_rows() - self.current_row }
identifier_body
cursor.rs
use super::result::PgResult; use super::row::PgRow; /// The type returned by various [`Connection`] methods. /// Acts as an iterator over `T`. pub struct Cursor<'a> { current_row: usize, db_result: &'a PgResult, } impl<'a> Cursor<'a> { pub(super) fn new(db_result: &'a PgResult) -> Self { Cursor { ...
else { None } } fn nth(&mut self, n: usize) -> Option<Self::Item> { self.current_row = (self.current_row + n).min(self.db_result.num_rows()); self.next() } fn size_hint(&self) -> (usize, Option<usize>) { let len = self.len(); (len, Some(len)) } ...
{ let row = self.db_result.get_row(self.current_row); self.current_row += 1; Some(row) }
conditional_block
cursor.rs
use super::result::PgResult; use super::row::PgRow; /// The type returned by various [`Connection`] methods. /// Acts as an iterator over `T`. pub struct Cursor<'a> { current_row: usize, db_result: &'a PgResult, } impl<'a> Cursor<'a> { pub(super) fn new(db_result: &'a PgResult) -> Self { Cursor { ...
(&mut self, n: usize) -> Option<Self::Item> { self.current_row = (self.current_row + n).min(self.db_result.num_rows()); self.next() } fn size_hint(&self) -> (usize, Option<usize>) { let len = self.len(); (len, Some(len)) } }
nth
identifier_name
cursor.rs
use super::result::PgResult; use super::row::PgRow; /// The type returned by various [`Connection`] methods. /// Acts as an iterator over `T`. pub struct Cursor<'a> { current_row: usize, db_result: &'a PgResult, }
pub(super) fn new(db_result: &'a PgResult) -> Self { Cursor { current_row: 0, db_result, } } } impl<'a> ExactSizeIterator for Cursor<'a> { fn len(&self) -> usize { self.db_result.num_rows() - self.current_row } } impl<'a> Iterator for Cursor<'a> { ty...
impl<'a> Cursor<'a> {
random_line_split
linkedlist.rs
enum List< T > { Empty, Cons{ head : T, tail : Box< List< T > > }, } impl< T > List< T > { fn mk_empty() -> List< T > { List::Empty } fn cons( value : T, list : List< T > ) -> List < T > { List::Cons{ head : value, tail : Box::new( list ) } } fn mk_one( value : T ) -> List< T > { List::cons( value, L...
println!( "{}", x ); } }
fn main() { let list = List::cons( 42, List::cons( 1337, List::mk_one( -1 ) ) ); for x in &list {
random_line_split
linkedlist.rs
enum List< T > { Empty, Cons{ head : T, tail : Box< List< T > > }, } impl< T > List< T > { fn mk_empty() -> List< T >
fn cons( value : T, list : List< T > ) -> List < T > { List::Cons{ head : value, tail : Box::new( list ) } } fn mk_one( value : T ) -> List< T > { List::cons( value, List::mk_empty() ) } } struct ListIterator< 'a, T : 'a > { cur : &'a List< T >, } impl< 'a, T > IntoIterator for &'a List< T > { type Item = ...
{ List::Empty }
identifier_body
linkedlist.rs
enum List< T > { Empty, Cons{ head : T, tail : Box< List< T > > }, } impl< T > List< T > { fn mk_empty() -> List< T > { List::Empty } fn cons( value : T, list : List< T > ) -> List < T > { List::Cons{ head : value, tail : Box::new( list ) } } fn mk_one( value : T ) -> List< T > { List::cons( value, L...
() { let list = List::cons( 42, List::cons( 1337, List::mk_one( -1 ) ) ); for x in &list { println!( "{}", x ); } }
main
identifier_name
audio_format.rs
use std::f64::consts::PI; use std::sync::atomic::{AtomicUsize, Ordering}; const CHANNELS: usize = 2; const DEFAULT_SAMPLE_RATE: usize = 44_100; static SAMPLE_RATE: AtomicUsize = AtomicUsize::new(DEFAULT_SAMPLE_RATE); //const FRAMES_PER_SECOND: usize = 10; const DEFAULT_CHUNK_SIZE: usize = 2048; //4410; static CHUNK_SI...
(sample_rate: usize) { SAMPLE_RATE.store(sample_rate, Ordering::Relaxed); } pub fn chunk_size() -> usize { CHUNK_SIZE.load(Ordering::Relaxed) } pub fn set_chunk_size(chunk_size: usize) { CHUNK_SIZE.store(chunk_size, Ordering::Relaxed); } pub fn frequence_coef() -> f64 { ...
set_sample_rate
identifier_name
audio_format.rs
use std::f64::consts::PI; use std::sync::atomic::{AtomicUsize, Ordering}; const CHANNELS: usize = 2; const DEFAULT_SAMPLE_RATE: usize = 44_100; static SAMPLE_RATE: AtomicUsize = AtomicUsize::new(DEFAULT_SAMPLE_RATE); //const FRAMES_PER_SECOND: usize = 10; const DEFAULT_CHUNK_SIZE: usize = 2048; //4410; static CHUNK_SI...
pub fn frequence_coef() -> f64 { (PI * 2.0) / SAMPLE_RATE.load(Ordering::Relaxed) as f64 } }
CHUNK_SIZE.load(Ordering::Relaxed) } pub fn set_chunk_size(chunk_size: usize) { CHUNK_SIZE.store(chunk_size, Ordering::Relaxed); }
random_line_split
domstringmap.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::DOMStringMapBinding; use dom::bindings::codegen::Bindings::DOMStringMapBindi...
(element: JSRef<HTMLElement>) -> DOMStringMap { DOMStringMap { reflector_: Reflector::new(), element: JS::from_rooted(element), } } pub fn new(element: JSRef<HTMLElement>) -> Temporary<DOMStringMap> { let window = window_from_node(element).root(); reflect...
new_inherited
identifier_name
domstringmap.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::DOMStringMapBinding; use dom::bindings::codegen::Bindings::DOMStringMapBindi...
fn NamedGetter(self, name: DOMString, found: &mut bool) -> DOMString { let element = self.element.root(); match element.r().get_custom_attr(name) { Some(value) => { *found = true; value.clone() }, None => { *found ...
{ let element = self.element.root(); element.r().set_custom_attr(name, value) }
identifier_body
domstringmap.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::DOMStringMapBinding; use dom::bindings::codegen::Bindings::DOMStringMapBindi...
}
random_line_split
conf.rs
/* Copyright (C) 2017 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARR...
(&self, key: &str) -> Option<&str> { let mut vptr: *const c_char = ptr::null_mut(); unsafe { if ConfGetChildValue(self.conf, CString::new(key).unwrap().as_ptr(), &mut vptr)!= 1 { return None; } ...
get_child_value
identifier_name
conf.rs
/* Copyright (C) 2017 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARR...
} if vptr == 1 { return true; } return false; } }
{ return false; }
conditional_block
conf.rs
/* Copyright (C) 2017 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARR...
CStr::from_ptr(vptr).to_bytes() }).unwrap(); return Some(value); } // Return the value of key as a boolean. A value that is not set is // the same as having it set to false. pub fn conf_get_bool(key: &str) -> bool { match conf_get(key) { Some(val) => { match val { ...
return None; } let value = str::from_utf8(unsafe{
random_line_split
shootout-regex-dna-single.rs
// The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ // // contributed by the Rust Project Developers // contributed by TeXitoi // contributed by BurntSushi extern crate regex; use std::io::{self, Read}; macro_rules! regex { ($re:expr) => { ::regex::Regex::new($re).unwrap() } } fn ma...
println!("{} {}", re.to_string(), re.find_iter(&seq).count()); } let substs = vec![ (regex!("B"), "(c|g|t)"), (regex!("D"), "(a|g|t)"), (regex!("H"), "(a|c|t)"), (regex!("K"), "(g|t)"), (regex!("M"), "(a|c)"), (regex!("N"), "(a|c|g|t)"), (regex!("...
{ let mut seq = String::with_capacity(50 * (1 << 20)); io::stdin().read_to_string(&mut seq).unwrap(); let ilen = seq.len(); seq = regex!(">[^\n]*\n|\n").replace_all(&seq, ""); let clen = seq.len(); let variants = vec![ regex!("agggtaaa|tttaccct"), regex!("[cgt]gggtaaa|tttaccc[a...
identifier_body
shootout-regex-dna-single.rs
// The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ // // contributed by the Rust Project Developers // contributed by TeXitoi // contributed by BurntSushi extern crate regex; use std::io::{self, Read}; macro_rules! regex { ($re:expr) => { ::regex::Regex::new($re).unwrap() } } fn
() { let mut seq = String::with_capacity(50 * (1 << 20)); io::stdin().read_to_string(&mut seq).unwrap(); let ilen = seq.len(); seq = regex!(">[^\n]*\n|\n").replace_all(&seq, ""); let clen = seq.len(); let variants = vec![ regex!("agggtaaa|tttaccct"), regex!("[cgt]gggtaaa|tttacc...
main
identifier_name
shootout-regex-dna-single.rs
// The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ //
// contributed by the Rust Project Developers // contributed by TeXitoi // contributed by BurntSushi extern crate regex; use std::io::{self, Read}; macro_rules! regex { ($re:expr) => { ::regex::Regex::new($re).unwrap() } } fn main() { let mut seq = String::with_capacity(50 * (1 << 20)); io::stdin().read_to_...
random_line_split
per_base_sequence_content.rs
use crate::trust_seq::group::BaseGroup; use crate::trust_seq::qc::{QCModule, QCReport, QCResult}; use crate::trust_seq::trust_seq::{TrustSeqConfig, TrustSeqErr}; use crate::trust_seq::utils::Sequence; use serde_json::map::Map; use serde_json::value; use serde_json::value::Value; use std::f64; use std::io::Write; pub s...
} } }
if b < 4 { self.counts[b][idx] += 1; }
random_line_split
per_base_sequence_content.rs
use crate::trust_seq::group::BaseGroup; use crate::trust_seq::qc::{QCModule, QCReport, QCResult}; use crate::trust_seq::trust_seq::{TrustSeqConfig, TrustSeqErr}; use crate::trust_seq::utils::Sequence; use serde_json::map::Map; use serde_json::value; use serde_json::value::Value; use std::f64; use std::io::Write; pub s...
else { write!( writer, "{}-{}\t{}\t{}\t{}\t{}\n", group.lower_count, group.upper_count, self.percents[idx][0], self.percents[idx][1], self.percents[idx][2], ...
{ write!( writer, "{}\t{}\t{}\t{}\t{}\n", group.lower_count, self.percents[idx][0], self.percents[idx][1], self.percents[idx][2], self.percents[idx][3] ...
conditional_block
per_base_sequence_content.rs
use crate::trust_seq::group::BaseGroup; use crate::trust_seq::qc::{QCModule, QCReport, QCResult}; use crate::trust_seq::trust_seq::{TrustSeqConfig, TrustSeqErr}; use crate::trust_seq::utils::Sequence; use serde_json::map::Map; use serde_json::value; use serde_json::value::Value; use std::f64; use std::io::Write; pub s...
(&self, reports: &mut Vec<Box<QCReport>>) -> Result<(), TrustSeqErr> { let seq_len = self.counts[0].len(); let groups = BaseGroup::make_base_groups(&self.config.group_type, seq_len); let mut percents: Vec<[f64; 4]> = Vec::new(); let mut max_gc_diff: f64 = 0.0; let mut max_at_diff...
calculate
identifier_name
scaffolding.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 https://mozilla.org/MPL/2.0/. */ use serde_json::{self, Value}; use std::env; use std::fs::{remove_file, File}; use std::path::Path; use std::proc...
{ if Command::new("python2.7") .arg("--version") .output() .unwrap() .status .success() { "python2.7" } else { "python" } .to_owned() }
identifier_body
scaffolding.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 https://mozilla.org/MPL/2.0/. */ use serde_json::{self, Value}; use std::env; use std::fs::{remove_file, File}; use std::path::Path; use std::proc...
#[cfg(windows)] fn find_python() -> String { if Command::new("python2.7.exe") .arg("--version") .output() .is_ok() { return "python2.7.exe".to_owned(); } if Command::new("python27.exe") .arg("--version") .output() .is_ok() { return "python2...
random_line_split
scaffolding.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 https://mozilla.org/MPL/2.0/. */ use serde_json::{self, Value}; use std::env; use std::fs::{remove_file, File}; use std::path::Path; use std::proc...
panic!("Can't find python (tried python27.exe and python.exe)! Try fixing PATH or setting the PYTHON env var"); } #[cfg(not(windows))] fn find_python() -> String { if Command::new("python2.7") .arg("--version") .output() .unwrap() .status .success() { "python2.7...
{ return "python.exe".to_owned(); }
conditional_block
scaffolding.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 https://mozilla.org/MPL/2.0/. */ use serde_json::{self, Value}; use std::env; use std::fs::{remove_file, File}; use std::path::Path; use std::proc...
() { let top = Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap()) .join("..") .join("..") .join(".."); let json = top .join("target") .join("doc") .join("servo") .join("css-properties.json"); if json.exists() { remove_file(&json).unwrap() } l...
properties_list_json
identifier_name
area_frame_allocator.rs
use core::ops::Range; use mem::{Frame, FrameAllocator}; use multiboot2::{MemoryArea, MemoryAreaIter}; pub struct AreaFrameAllocator { area: Option<&'static MemoryArea>, areas: MemoryAreaIter, next: Frame, kernel: Range<Frame>, multiboot: Range<Frame>, } impl FrameAllocator for AreaFrameAllocator ...
fn select_next_area(&mut self) { self.area = self.areas .clone() .filter(|area| { let last_address = area.base_addr + area.length - 1; let frame = Frame::containing(last_address as usize); frame >= self.next && !(self.ke...
{ let mut allocator = AreaFrameAllocator { area: None, areas: memory_areas, next: Frame::containing(0), kernel: Range { start: Frame::containing(kernel_start), end: Frame::containing(kernel_end), }, multiboot...
identifier_body
area_frame_allocator.rs
use core::ops::Range; use mem::{Frame, FrameAllocator}; use multiboot2::{MemoryArea, MemoryAreaIter}; pub struct AreaFrameAllocator { area: Option<&'static MemoryArea>, areas: MemoryAreaIter, next: Frame, kernel: Range<Frame>, multiboot: Range<Frame>, } impl FrameAllocator for AreaFrameAllocator ...
areas: memory_areas, next: Frame::containing(0), kernel: Range { start: Frame::containing(kernel_start), end: Frame::containing(kernel_end), }, multiboot: Range { start: Frame::containing(multiboot_start), ...
memory_areas: MemoryAreaIter) -> AreaFrameAllocator { let mut allocator = AreaFrameAllocator { area: None,
random_line_split
area_frame_allocator.rs
use core::ops::Range; use mem::{Frame, FrameAllocator}; use multiboot2::{MemoryArea, MemoryAreaIter}; pub struct AreaFrameAllocator { area: Option<&'static MemoryArea>, areas: MemoryAreaIter, next: Frame, kernel: Range<Frame>, multiboot: Range<Frame>, } impl FrameAllocator for AreaFrameAllocator ...
(&mut self) -> Option<Frame> { if let Some(area) = self.area { let frame = Frame { number: self.next.number }; let last_frame = { let last_address = area.base_addr + area.length - 1; Frame::containing(last_address as usize) }; if ...
alloc
identifier_name
area_frame_allocator.rs
use core::ops::Range; use mem::{Frame, FrameAllocator}; use multiboot2::{MemoryArea, MemoryAreaIter}; pub struct AreaFrameAllocator { area: Option<&'static MemoryArea>, areas: MemoryAreaIter, next: Frame, kernel: Range<Frame>, multiboot: Range<Frame>, } impl FrameAllocator for AreaFrameAllocator ...
else { self.next.number += 1; return Some(frame); } } None } fn free(&mut self, _frame: Frame) { unimplemented!() } } impl AreaFrameAllocator { pub fn new(kernel_start: usize, kernel_end: usize, multiboo...
{ self.select_next_area(); return self.alloc(); }
conditional_block
interpret.rs
//! A depth-first interpreter for NFAs. use lexer::nfa::{NFA, NFAStateIndex, START, StateKind, Noop, Other, Test}; use std::cmp::max; /// Interpret `nfa` applied to `test`, returning the longest matching /// string that we can find (if any). pub fn interpret<'text>(nfa: &NFA, text: &'text str) -> Option<&'text str> {...
{ if !v.contains(&t) { v.push(t); } }
identifier_body
interpret.rs
//! A depth-first interpreter for NFAs. use lexer::nfa::{NFA, NFAStateIndex, START, StateKind, Noop, Other, Test}; use std::cmp::max; /// Interpret `nfa` applied to `test`, returning the longest matching /// string that we can find (if any). pub fn interpret<'text>(nfa: &NFA, text: &'text str) -> Option<&'text str> {...
<T:Eq>(v: &mut Vec<T>, t: T) { if!v.contains(&t) { v.push(t); } }
push
identifier_name
interpret.rs
//! A depth-first interpreter for NFAs. use lexer::nfa::{NFA, NFAStateIndex, START, StateKind, Noop, Other, Test}; use std::cmp::max; /// Interpret `nfa` applied to `test`, returning the longest matching /// string that we can find (if any). pub fn interpret<'text>(nfa: &NFA, text: &'text str) -> Option<&'text str> {...
// transition test edges let mut tests = 0; for edge in nfa.edges::<Test>(state) { if edge.label.contains_char(ch) { push(&mut stack, (edge.to, offset1)); tests += 1; } } // should *never* match more than one test, because ...
let offset1 = offset + ch.len_utf8();
random_line_split
register.rs
use super::login::LoginCredentials; use super::view; use crate::{ core::{prelude::*, usecases}, infrastructure::notify, ports::web::sqlite::Connections, }; use maud::Markup; use rocket::{ self, http::RawStr, request::{FlashMessage, Form}, response::{Flash, Redirect}, }; #[get("/register")] ...
{ match db.exclusive() { Err(_) => Err(Flash::error( Redirect::to(uri!(get_email_confirmation: token)), "We are so sorry! An internal server error has occurred. Please try again later.", )), Ok(db) => match usecases::confirm_email_address(&*db, token.as_str()) { ...
identifier_body
register.rs
use super::login::LoginCredentials; use super::view; use crate::{ core::{prelude::*, usecases}, infrastructure::notify, ports::web::sqlite::Connections, }; use maud::Markup; use rocket::{ self, http::RawStr, request::{FlashMessage, Form}, response::{Flash, Redirect}, }; #[get("/register")] ...
( db: Connections, credentials: Form<LoginCredentials>, ) -> std::result::Result<Flash<Redirect>, Flash<Redirect>> { match db.exclusive() { Err(_) => Err(Flash::error( Redirect::to(uri!(get_register)), "We are so sorry! An internal server error has occurred. Please try again ...
post_register
identifier_name
register.rs
use super::login::LoginCredentials; use super::view; use crate::{ core::{prelude::*, usecases}, infrastructure::notify, ports::web::sqlite::Connections, }; use maud::Markup; use rocket::{ self, http::RawStr, request::{FlashMessage, Form}, response::{Flash, Redirect}, }; #[get("/register")] ...
#[post("/register", data = "<credentials>")] pub fn post_register( db: Connections, credentials: Form<LoginCredentials>, ) -> std::result::Result<Flash<Redirect>, Flash<Redirect>> { match db.exclusive() { Err(_) => Err(Flash::error( Redirect::to(uri!(get_register)), "We are ...
view::register(flash) }
random_line_split
print.rs
.0.is_empty() { self.0 = vec![Param::Int(0); 52]; } self.0[idx] = param; Ok(()) } fn get(&self, name: char) -> Result<Param, CapError> { let idx = self.idx(name)?; if self.0.is_empty() { return Err(var_error(name)); } match self.0[...
(cap: &[u8]) -> CapReader { CapReader { cap, idx: 0 } } fn read(&mut self) -> Option<u8> { if self.idx < self.cap.len() { self.idx += 1; Some(self.cap[self.idx - 1]) } else { None } } fn peek(&mut self) -> Option<u8> { if self...
new
identifier_name
print.rs
self.0.is_empty() { self.0 = vec![Param::Int(0); 52]; } self.0[idx] = param; Ok(()) } fn get(&self, name: char) -> Result<Param, CapError> { let idx = self.idx(name)?; if self.0.is_empty() { return Err(var_error(name)); } match se...
} } impl<'a> BytePusher for Write + 'a {} #[derive(Copy, Clone)] enum PadState { Normal, Dollar, Number(u32, NumPart), Finish(u32, NumPart), } #[derive(Copy, Clone, PartialEq)] enum NumPart { Whole, Dot, Frac, } /// Print a string capability, applying padding. /// /// `pad_factor` sh...
random_line_split
print.rs
.0.is_empty() { self.0 = vec![Param::Int(0); 52]; } self.0[idx] = param; Ok(()) } fn get(&self, name: char) -> Result<Param, CapError> { let idx = self.idx(name)?; if self.0.is_empty() { return Err(var_error(name)); } match self.0[...
} struct CapReader<'a> { cap: &'a [u8], idx: usize, } impl<'a> CapReader<'a> { fn new(cap: &[u8]) -> CapReader { CapReader { cap, idx: 0 } } fn read(&mut self) -> Option<u8> { if self.idx < self.cap.len() { self.idx += 1; Some(self.cap[self.idx - 1]) ...
{ self.0.push(param); }
identifier_body
print.rs
.0.is_empty() { self.0 = vec![Param::Int(0); 52]; } self.0[idx] = param; Ok(()) } fn get(&self, name: char) -> Result<Param, CapError> { let idx = self.idx(name)?; if self.0.is_empty() { return Err(var_error(name)); } match self.0[...
)); } // arithmetic operators op @ '+' | op @ '-' | op @ '*' | op @ '/' | op @'m' => { let (v2, v1) = (stack.pop_int()?, stack.pop_int()?); let res = match op { '+' => v1.wrapping_add(v2), '-' => v1.wrapping_sub(...
{ 0 }
conditional_block
issue-38033.rs
// Copyright 2016 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) -> Result<Self::Item, Self::Error> { let elems = mem::replace(&mut self.elems, Vec::new()); Ok(elems.into_iter().map(|e| { e }).collect::<Vec<_>>()) } }
poll
identifier_name
issue-38033.rs
// Copyright 2016 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 poll(&mut self) -> Result<Self::Item, Self::Error>; } trait IntoFuture { type Future: Future<Item=Self::Item, Error=Self::Error>; type Item; type Error; fn into_future(self) -> Self::Future; } impl<F: Future> IntoFuture for F { type Future = F; type Item = F::Item; type Error = F::...
type Error;
random_line_split
issue-38033.rs
// Copyright 2016 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 ...
impl<I> Future for JoinAll<I> where I: IntoIterator, I::Item: IntoFuture, { type Item = Vec<<I::Item as IntoFuture>::Item>; type Error = <I::Item as IntoFuture>::Error; fn poll(&mut self) -> Result<Self::Item, Self::Error> { let elems = mem::replace(&mut self.elems, Vec::new()); ...
{ JoinAll { elems: vec![] } }
identifier_body
mod.rs
//! Structures that can be passed into Weld. //! //! This currently defines the type layout specified for the single threaded backend. In general, //! type layouts vary from backend to backend especially for builders. //! //! # Primitives //! //! Primitives in Weld match their Rust counterparts, _except for booleans_. ...
for i in 0..self.len { let v1 = unsafe { (*self.data.offset(i as isize)).clone() }; let v2 = unsafe { (*other.data.offset(i as isize)).clone() }; if v1!= v2 { return false; } } true } } impl<T> fmt::Display for WeldVec<T> wher...
{ return false; }
conditional_block
mod.rs
//! Structures that can be passed into Weld. //! //! This currently defines the type layout specified for the single threaded backend. In general, //! type layouts vary from backend to backend especially for builders. //! //! # Primitives //! //! Primitives in Weld match their Rust counterparts, _except for booleans_. ...
<K, V> { d: Dict<K, V>, } /// The `groupmerger` builder type. #[derive(Clone, Debug)] #[repr(C)] pub struct GroupMerger<K, V> { d: Dict<K, WeldVec<V>>, } // Ensures that the sizes of the types defined here match the sizes of the types in the backend. #[test] fn size_check() { use crate::ast::BinOpKind::Ad...
DictMerger
identifier_name
mod.rs
//! Structures that can be passed into Weld. //! //! This currently defines the type layout specified for the single threaded backend. In general, //! type layouts vary from backend to backend especially for builders. //! //! # Primitives //! //! Primitives in Weld match their Rust counterparts, _except for booleans_. ...
{ fn from(s: &'a U) -> WeldVec<T> { WeldVec::new(s.as_ref().as_ptr(), s.as_ref().len() as i64) } } impl<T> PartialEq for WeldVec<T> where T: PartialEq + Clone, { fn eq(&self, other: &WeldVec<T>) -> bool { if self.len!= other.len { return false; } for i in 0.....
impl<'a, T, U> From<&'a U> for WeldVec<T> where U: AsRef<[T]>,
random_line_split
mod.rs
//! Structures that can be passed into Weld. //! //! This currently defines the type layout specified for the single threaded backend. In general, //! type layouts vary from backend to backend especially for builders. //! //! # Primitives //! //! Primitives in Weld match their Rust counterparts, _except for booleans_. ...
} impl<'a, T, U> From<&'a U> for WeldVec<T> where U: AsRef<[T]>, { fn from(s: &'a U) -> WeldVec<T> { WeldVec::new(s.as_ref().as_ptr(), s.as_ref().len() as i64) } } impl<T> PartialEq for WeldVec<T> where T: PartialEq + Clone, { fn eq(&self, other: &WeldVec<T>) -> bool { if self.len...
{ WeldVec { data: ptr, len } }
identifier_body
lib.rs
// `encode` and `decode` are used instead of `ser` and `de` to avoid confusion with the serder // Serializer and Deserializer traits which occupy a similar namespace. mod cow_iter; pub mod decode; pub mod encode; mod into_cow; pub use crate::decode::Deserializer; pub use crate::encode::Serializer; pub use crate::into_...
pub trait RedisDeserialize<'de, T> where T: serde::de::Deserialize<'de>, { fn deserialize(&'de self) -> decode::Result<T>; } impl<'de, T> RedisDeserialize<'de, T> for redis::Value where T: serde::de::Deserialize<'de>, { fn deserialize(&'de self) -> decode::Result<T> { serde::de::Deserialize::de...
random_line_split
lib.rs
// `encode` and `decode` are used instead of `ser` and `de` to avoid confusion with the serder // Serializer and Deserializer traits which occupy a similar namespace. mod cow_iter; pub mod decode; pub mod encode; mod into_cow; pub use crate::decode::Deserializer; pub use crate::encode::Serializer; pub use crate::into_...
() { let v = Value::Bulk(vec![Value::Int(5), Value::Data(b"hello".to_vec())]); let actual: (u8, String) = from_redis_value(v).unwrap(); let expected = (5, "hello".into()); assert_eq!(expected, actual); } #[test] fn from_redis_value_works_with_borrow() { let v = Val...
from_redis_value_works_with_owned
identifier_name
lib.rs
// `encode` and `decode` are used instead of `ser` and `de` to avoid confusion with the serder // Serializer and Deserializer traits which occupy a similar namespace. mod cow_iter; pub mod decode; pub mod encode; mod into_cow; pub use crate::decode::Deserializer; pub use crate::encode::Serializer; pub use crate::into_...
} #[cfg(test)] mod tests { use super::*; use redis::Value; #[test] fn chain_deserialize_works() { let v = Value::Bulk(vec![Value::Int(5), Value::Data(b"hello".to_vec())]); let actual: (u8, String) = v.deserialize().unwrap(); let expected = (5, "hello".into()); assert...
{ serde::de::Deserialize::deserialize(Deserializer::new(self)) }
identifier_body
withdrawn_routes.rs
use types::*; use core::fmt; /// This is a variable-length field that contains a list of IP /// address prefixes for the routes that are being withdrawn from /// service. #[derive(Clone)] pub struct WithdrawnRoutes<'a> { pub inner: &'a [u8], error: Option<BgpError>, } impl<'a> WithdrawnRoutes<'a> { pub fn...
(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fmt.debug_list().entries(self.clone()).finish() } } #[cfg(test)] mod tests { use super::*; #[test] fn parse_withdrawn_routes() { let bytes = &[24, 103, 230, 182, // masklen, a, b, c 23, 103, 31, 178, ...
fmt
identifier_name
withdrawn_routes.rs
use types::*; use core::fmt; /// This is a variable-length field that contains a list of IP /// address prefixes for the routes that are being withdrawn from /// service. #[derive(Clone)] pub struct WithdrawnRoutes<'a> { pub inner: &'a [u8], error: Option<BgpError>, } impl<'a> WithdrawnRoutes<'a> { pub fn...
if self.inner.len() == 0 { return None; } if self.inner.len() < 1 { let err = BgpError::BadLength; self.error = Some(err); return Some(Err(err)); } let mask_len = self.inner[0] as usize; let prefix_len = (mask_len+15) / 8; ...
{ return None; }
conditional_block
withdrawn_routes.rs
use types::*; use core::fmt; /// This is a variable-length field that contains a list of IP /// address prefixes for the routes that are being withdrawn from /// service. #[derive(Clone)] pub struct WithdrawnRoutes<'a> { pub inner: &'a [u8], error: Option<BgpError>, } impl<'a> WithdrawnRoutes<'a> { pub fn...
} #[cfg(test)] mod tests { use super::*; #[test] fn parse_withdrawn_routes() { let bytes = &[24, 103, 230, 182, // masklen, a, b, c 23, 103, 31, 178, 23, 103, 253, 46, 22, 150, 107, 48, 23, 150, 242, 106, ...
random_line_split
issue-18501.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 ...
() { issue::pass_method(); }
main
identifier_name
issue-18501.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 ...
{ issue::pass_method(); }
identifier_body
issue-18501.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
// option. This file may not be copied, modified, or distributed // except according to those terms. // Test that we don't ICE when inlining a function from another // crate that uses a trait method as a value due to incorrectly // translating the def ID of the trait during AST decoding. // aux-build:issue-18501.rs /...
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
random_line_split
hailstone.rs
// Implements http://rosettacode.org/wiki/Hailstone_sequence // Define a struct which stores the state for the iterator. #![feature(iter_cmp)] struct Hailstone { next: usize, // Accessible only to the current module. pub start: usize // Publically accessible. } impl Hailstone { // Define a constructor for ...
(n: usize) -> Hailstone { Hailstone { next: n, start: n } } } // Implement the hailstone iteration sequence. impl Iterator for Hailstone { type Item = usize; // This gets called to fetch the next item of the iterator. fn next(&mut self) -> Option<usize> { // We need to cache the current...
new
identifier_name
hailstone.rs
// Implements http://rosettacode.org/wiki/Hailstone_sequence // Define a struct which stores the state for the iterator. #![feature(iter_cmp)] struct Hailstone { next: usize, // Accessible only to the current module. pub start: usize // Publically accessible. } impl Hailstone { // Define a constructor for ...
#[cfg(not(test))] fn main() { // Find the hailstone for 27. let two_seven = Hailstone::new(27).collect::<Vec<usize>>(); let ts_len = two_seven.len(); println!("Testing: {}, Length: {}, Values: {:?}...{:?}", two_seven[0], ts_len, &two_seven[0..4], &two_se...
{ (0..limit).map(|n| (n, Hailstone::new(n).count())) .max_by(|&(_, count)| count) .unwrap() }
identifier_body
hailstone.rs
// Implements http://rosettacode.org/wiki/Hailstone_sequence // Define a struct which stores the state for the iterator. #![feature(iter_cmp)] struct Hailstone { next: usize, // Accessible only to the current module. pub start: usize // Publically accessible. } impl Hailstone { // Define a constructor for ...
type Item = usize; // This gets called to fetch the next item of the iterator. fn next(&mut self) -> Option<usize> { // We need to cache the current value. let current = self.next; // And then calculate the 'next' self.next = match current { 0 => { ...
random_line_split
header.rs
// This file is part of oxideNews-gtk // // Copyright © 2017-2018 red-oxide Developers // // This program 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 optio...
{ pub container: HeaderBar, pub add: Add, pub about: About, pub pages: StackSwitcher, } impl Header { pub fn new() -> Header { // Creates the main header bar container widget. let container = HeaderBar::new(); // Enable the window controls within this head...
eader
identifier_name
header.rs
// This file is part of oxideNews-gtk // // Copyright © 2017-2018 red-oxide Developers // // This program 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 optio...
container.pack_end(&about.button); // Returns the header and all of it's state Header { container, add, about, pages, } } }
// Creates the main header bar container widget. let container = HeaderBar::new(); // Enable the window controls within this headerbar. container.set_show_close_button(true); let pages = StackSwitcher::new(); // Add feeds let add = Add::new(); // pref...
identifier_body
header.rs
// This file is part of oxideNews-gtk // // Copyright © 2017-2018 red-oxide Developers // // This program 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 optio...
// GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // use gtk::{Button, HeaderBar, IconSize, StackSwitcher}; use gtk::prelude::*; use super::{About...
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
random_line_split
embed.rs
#[cfg(feature = "model")] use crate::builder::CreateEmbed; #[cfg(feature = "model")] use crate::internal::prelude::*; #[cfg(feature = "model")] use crate::utils; #[cfg(feature = "utils")] use crate::utils::Colour; /// Represents a rich embed which allows using richer markdown, multiple fields /// and more. This was he...
{ Self::_new(name.into(), value.into(), inline) } fn _new(name: String, value: String, inline: bool) -> Self { Self { inline, name, value, } } } /// Footer information for an embed. #[derive(Clone, Debug, Deserialize, Serialize)] #[non_exhaus...
pub fn new<T, U>(name: T, value: U, inline: bool) -> Self where T: Into<String>, U: Into<String>,
random_line_split
embed.rs
#[cfg(feature = "model")] use crate::builder::CreateEmbed; #[cfg(feature = "model")] use crate::internal::prelude::*; #[cfg(feature = "model")] use crate::utils; #[cfg(feature = "utils")] use crate::utils::Colour; /// Represents a rich embed which allows using richer markdown, multiple fields /// and more. This was he...
<T, U>(name: T, value: U, inline: bool) -> Self where T: Into<String>, U: Into<String>, { Self::_new(name.into(), value.into(), inline) } fn _new(name: String, value: String, inline: bool) -> Self { Self { inline, name, value, ...
new
identifier_name
write_with_newline.rs
// FIXME: Ideally these suggestions would be fixed via rustfix. Blocked by rust-lang/rust#53934 // // run-rustfix #![allow(clippy::write_literal)] #![warn(clippy::write_with_newline)] use std::io::Write; fn
() { let mut v = Vec::new(); // These should fail write!(&mut v, "Hello\n"); write!(&mut v, "Hello {}\n", "world"); write!(&mut v, "Hello {} {}\n", "world", "#2"); write!(&mut v, "{}\n", 1265); write!(&mut v, "\n"); // These should be fine write!(&mut v, ""); write!(&mut v, "He...
main
identifier_name
write_with_newline.rs
// FIXME: Ideally these suggestions would be fixed via rustfix. Blocked by rust-lang/rust#53934 // // run-rustfix #![allow(clippy::write_literal)] #![warn(clippy::write_with_newline)] use std::io::Write; fn main()
write!(&mut v, "like eof\n\n"); write!(&mut v, "Hello {} {}\n\n", "world", "#2"); writeln!(&mut v, "\ndon't\nwarn\nfor\nmultiple\nnewlines\n"); // #3126 writeln!(&mut v, "\nbla\n\n"); // #3126 // Escaping write!(&mut v, "\\n"); // #3514 write!(&mut v, "\\\n"); // should fail write!(&mut...
{ let mut v = Vec::new(); // These should fail write!(&mut v, "Hello\n"); write!(&mut v, "Hello {}\n", "world"); write!(&mut v, "Hello {} {}\n", "world", "#2"); write!(&mut v, "{}\n", 1265); write!(&mut v, "\n"); // These should be fine write!(&mut v, ""); write!(&mut v, "Hello...
identifier_body
write_with_newline.rs
// FIXME: Ideally these suggestions would be fixed via rustfix. Blocked by rust-lang/rust#53934 // // run-rustfix #![allow(clippy::write_literal)] #![warn(clippy::write_with_newline)] use std::io::Write;
let mut v = Vec::new(); // These should fail write!(&mut v, "Hello\n"); write!(&mut v, "Hello {}\n", "world"); write!(&mut v, "Hello {} {}\n", "world", "#2"); write!(&mut v, "{}\n", 1265); write!(&mut v, "\n"); // These should be fine write!(&mut v, ""); write!(&mut v, "Hello")...
fn main() {
random_line_split
arithmetic.rs
#[macro_use] extern crate nom; use nom::{IResult,digit}; // Parser definition use std::str; use std::str::FromStr; // We parse any expr surrounded by parens, ignoring all whitespaces around those named!(parens<i64>, ws!(delimited!( tag!("("), expr, tag!(")") )) ); // We transform an integer string into a i64, igno...
#[test] fn expr_test() { assert_eq!(expr(&b" 1 + 2 "[..]), IResult::Done(&b""[..], 3)); assert_eq!(expr(&b" 12 + 6 - 4+ 3"[..]), IResult::Done(&b""[..], 17)); assert_eq!(expr(&b" 1 + 2*3 + 4"[..]), IResult::Done(&b""[..], 11)); } #[test] fn parens_test() { assert_eq!(expr(&b" ( 2 )"[..]), IResult::Done(&b"...
assert_eq!(term(&b" 2* 3 *2 *2 / 3"[..]), IResult::Done(&b""[..], 8)); assert_eq!(term(&b" 48 / 3/2"[..]), IResult::Done(&b""[..], 8)); }
random_line_split
arithmetic.rs
#[macro_use] extern crate nom; use nom::{IResult,digit}; // Parser definition use std::str; use std::str::FromStr; // We parse any expr surrounded by parens, ignoring all whitespaces around those named!(parens<i64>, ws!(delimited!( tag!("("), expr, tag!(")") )) ); // We transform an integer string into a i64, igno...
#[test] fn parens_test() { assert_eq!(expr(&b" ( 2 )"[..]), IResult::Done(&b""[..], 2)); assert_eq!(expr(&b" 2* ( 3 + 4 ) "[..]), IResult::Done(&b""[..], 14)); assert_eq!(expr(&b" 2*2 / ( 5 - 1) + 3"[..]), IResult::Done(&b""[..], 4)); }
{ assert_eq!(expr(&b" 1 + 2 "[..]), IResult::Done(&b""[..], 3)); assert_eq!(expr(&b" 12 + 6 - 4+ 3"[..]), IResult::Done(&b""[..], 17)); assert_eq!(expr(&b" 1 + 2*3 + 4"[..]), IResult::Done(&b""[..], 11)); }
identifier_body
arithmetic.rs
#[macro_use] extern crate nom; use nom::{IResult,digit}; // Parser definition use std::str; use std::str::FromStr; // We parse any expr surrounded by parens, ignoring all whitespaces around those named!(parens<i64>, ws!(delimited!( tag!("("), expr, tag!(")") )) ); // We transform an integer string into a i64, igno...
() { assert_eq!(expr(&b" ( 2 )"[..]), IResult::Done(&b""[..], 2)); assert_eq!(expr(&b" 2* ( 3 + 4 ) "[..]), IResult::Done(&b""[..], 14)); assert_eq!(expr(&b" 2*2 / ( 5 - 1) + 3"[..]), IResult::Done(&b""[..], 4)); }
parens_test
identifier_name
simplify_branches.rs
// Copyright 2016 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 ...
else { continue } }, TerminatorKind::Assert { target, cond: Operand::Constant(ref c), expected,.. } if (c.literal.assert_bool(tcx) == Some(true)) == expected => { TerminatorKind::Goto { t...
{ let (otherwise, targets) = targets.split_last().unwrap(); let mut ret = TerminatorKind::Goto { target: *otherwise }; for (&v, t) in values.iter().zip(targets.iter()) { if v == constint { ...
conditional_block
simplify_branches.rs
// Copyright 2016 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 ...
} impl MirPass for SimplifyBranches { fn name<'a>(&'a self) -> Cow<'a, str> { Cow::Borrowed(&self.label) } fn run_pass<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, _src: MirSource, mir: &mut Mir<'tcx>) { for bl...
{ SimplifyBranches { label: format!("SimplifyBranches-{}", label) } }
identifier_body
simplify_branches.rs
// Copyright 2016 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 ...
use transform::{MirPass, MirSource}; use std::borrow::Cow; pub struct SimplifyBranches { label: String } impl SimplifyBranches { pub fn new(label: &str) -> Self { SimplifyBranches { label: format!("SimplifyBranches-{}", label) } } } impl MirPass for SimplifyBranches { fn name<'a>(&'a self) -> Co...
use rustc::mir::*;
random_line_split
simplify_branches.rs
// Copyright 2016 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 ...
<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, _src: MirSource, mir: &mut Mir<'tcx>) { for block in mir.basic_blocks_mut() { let terminator = block.terminator_mut(); terminator.kind = match terminator.kind { ...
run_pass
identifier_name
server.rs
#![feature(core)] extern crate eve; extern crate getopts; extern crate url; extern crate core; use std::thread; use std::env; use getopts::Options; use std::net::SocketAddr; use core::str::FromStr; use eve::server; use eve::login; #[allow(dead_code)] fn main()
return; } // parse static file server address let default_addr = SocketAddr::from_str("0.0.0.0:8080").unwrap(); let addr = match matches.opt_str("f") { Some(ip) => { match SocketAddr::from_str(&*ip) { Ok(addr) => addr, Err(_) => { println!("WARNING: Could not parse static file...
{ // handle command line arguments let args: Vec<String> = env::args().collect(); // define the command line arguments let mut opts = Options::new(); opts.optopt("f", "faddress", "specify a socket address for the static file server. Defaults to 0.0.0.0:8080","SOCKET ADDRESS"); opts.optopt("s", "saves", "s...
identifier_body
server.rs
#![feature(core)] extern crate eve; extern crate getopts; extern crate url; extern crate core; use std::thread; use std::env; use getopts::Options; use std::net::SocketAddr; use core::str::FromStr; use eve::server; use eve::login; #[allow(dead_code)] fn main() { // handle command line arguments let args: Vec<St...
// print the help menu if matches.opt_present("h") { print!("{}", opts.usage("")); return; } // parse static file server address let default_addr = SocketAddr::from_str("0.0.0.0:8080").unwrap(); let addr = match matches.opt_str("f") { Some(ip) => { match SocketAddr::from_s...
random_line_split
server.rs
#![feature(core)] extern crate eve; extern crate getopts; extern crate url; extern crate core; use std::thread; use std::env; use getopts::Options; use std::net::SocketAddr; use core::str::FromStr; use eve::server; use eve::login; #[allow(dead_code)] fn main() { // handle command line arguments let args: Vec<S...
Err(f) => { panic!(f.to_string()) } }; // print the help menu if matches.opt_present("h") { print!("{}", opts.usage("")); return; } // parse static file server address let default_addr = SocketAddr::from_str("0.0.0.0:8080").unwrap(); let addr = match matches.opt_st...
{ m }
conditional_block
server.rs
#![feature(core)] extern crate eve; extern crate getopts; extern crate url; extern crate core; use std::thread; use std::env; use getopts::Options; use std::net::SocketAddr; use core::str::FromStr; use eve::server; use eve::login; #[allow(dead_code)] fn
() { // handle command line arguments let args: Vec<String> = env::args().collect(); // define the command line arguments let mut opts = Options::new(); opts.optopt("f", "faddress", "specify a socket address for the static file server. Defaults to 0.0.0.0:8080","SOCKET ADDRESS"); opts.optopt("s", "saves",...
main
identifier_name
sampler_object.rs
use Display; use DrawError; use std::sync::mpsc; use uniforms::SamplerBehavior; use gl; use context::{self, GlVersion}; use version::Api; use GlObject; use ToGlEnum; /// An OpenGL sampler object. pub struct SamplerObject { display: Display, id: gl::types::GLuint, } impl SamplerObject {
/// Builds a new sampler object. pub fn new(display: &Display, behavior: &SamplerBehavior) -> SamplerObject { // making sure that the backend supports samplers assert!(display.context.context.get_version() >= &GlVersion(Api::Gl, 3, 2) || display.context.context.get_extensions().g...
random_line_split
sampler_object.rs
use Display; use DrawError; use std::sync::mpsc; use uniforms::SamplerBehavior; use gl; use context::{self, GlVersion}; use version::Api; use GlObject; use ToGlEnum; /// An OpenGL sampler object. pub struct
{ display: Display, id: gl::types::GLuint, } impl SamplerObject { /// Builds a new sampler object. pub fn new(display: &Display, behavior: &SamplerBehavior) -> SamplerObject { // making sure that the backend supports samplers assert!(display.context.context.get_version() >= &GlVersion(...
SamplerObject
identifier_name
asm.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...
<'a>(bcx: &'a Block<'a>, ia: &ast::InlineAsm) -> &'a Block<'a> { let fcx = bcx.fcx; let mut bcx = bcx; let mut constraints = Vec::new(); let mut output_types = Vec::new(); let temp_scope = fcx.push_custom_cleanup_scope(); // Prepare the output operands let outputs =...
trans_inline_asm
identifier_name
asm.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...
else { clobbers.push_str(ia.clobbers.get()); } // Add the clobbers to our constraints list if clobbers.len()!= 0 && constraints.len()!= 0 { constraints.push_char(','); constraints.push_str(clobbers.as_slice()); } else { constraints.push_str(clobbers.as_slice()); } ...
{ clobbers = format!("{},{}", ia.clobbers.get(), clobbers); }
conditional_block
asm.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...
#[cfg(target_arch = "x86")] #[cfg(target_arch = "x86_64")] fn get_clobbers() -> String { "~{dirflag},~{fpsr},~{flags}".to_string() }
{ "".to_string() }
identifier_body
asm.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...
#[cfg(target_arch = "x86")] #[cfg(target_arch = "x86_64")] fn get_clobbers() -> String { "~{dirflag},~{fpsr},~{flags}".to_string() }
}
random_line_split
locus.rs
//! Provide a location. //! //! ```text //! _ _ _ //! _ __ ___| (_)___(_) ___ _ __ //! | '__/ _ \ | / __| |/ _ \| '_ \ //! | | | __/ | \__ \ | (_) | | | | //! |_| \___|_|_|___/_|\___/|_| |_| //! ``` //! The relision term rewriting library. //! //! # License //! //! Copyright (c) 2015 by Stacy Prowell....
(&self, form: &mut fmt::Formatter) -> fmt::Result { match *self { Locus::Internal => write!(form, ""), Locus::Console(line, column) => { write!(form, "{}:{}", line, column) }, Locus::File(ref name, line, column) => { write!(form, "{}:{}:{}", name, line, column) } } } }
fmt
identifier_name