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 |
|---|---|---|---|---|
enum-headings.rs | #![crate_name = "foo"]
// @has foo/enum.Token.html
/// A token!
/// # First
/// Some following text...
// @has - '//h2[@id="first"]' "First"
pub enum | {
/// A declaration!
/// # Variant-First
/// Some following text...
// @has - '//h4[@id="variant-first"]' "Variant-First"
Declaration {
/// A version!
/// # Variant-Field-First
/// Some following text...
// @has - '//h5[@id="variant-field-first"]' "Variant-Field-Firs... | Token | identifier_name |
union_dtor_1_0.rs | /* automatically generated by rust-bindgen */
#![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl<T> __BindgenUnionField<T> {
#[inline]
pub fn new() -> Self {
__BindgenUni... |
}
impl<T> ::std::cmp::Eq for __BindgenUnionField<T> {}
#[repr(C)]
#[derive(Debug, Default)]
pub struct UnionWithDtor {
pub mFoo: __BindgenUnionField<::std::os::raw::c_int>,
pub mBar: __BindgenUnionField<*mut ::std::os::raw::c_void>,
pub bindgen_union_field: u64,
}
#[test]
fn bindgen_test_layout_UnionWithDt... | {
true
} | identifier_body |
union_dtor_1_0.rs | /* automatically generated by rust-bindgen */
#![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl<T> __BindgenUnionField<T> {
#[inline]
pub fn new() -> Self {
__BindgenUni... | pub fn UnionWithDtor_UnionWithDtor_destructor(this: *mut UnionWithDtor);
}
impl UnionWithDtor {
#[inline]
pub unsafe fn destruct(&mut self) {
UnionWithDtor_UnionWithDtor_destructor(self)
}
} | )
);
}
extern "C" {
#[link_name = "\u{1}_ZN13UnionWithDtorD1Ev"] | random_line_split |
union_dtor_1_0.rs | /* automatically generated by rust-bindgen */
#![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl<T> __BindgenUnionField<T> {
#[inline]
pub fn new() -> Self {
__BindgenUni... | (&mut self) {
UnionWithDtor_UnionWithDtor_destructor(self)
}
}
| destruct | identifier_name |
barebone_blink.rs | //! Flash the BeagleBone USR1 LED 5 times at 2Hz.
//!
//! The PRU code notifies the host processor every time the LED is flashed by triggering Evtout0.
//! The 6-th event out is interpreted as a completion notification.
extern crate prusst;
use prusst::{Pruss, IntcConfig, Evtout, Sysevt};
use std::fs::File;
use std... | let irq = pruss.intc.register_irq(Evtout::E0);
// Open and load the PRU binary.
let mut pru_binary = File::open("examples/barebone_blink_pru0.bin").unwrap();
// Temporarily take control of the LED.
echo("none", LED_TRIGGER_PATH);
// Run the PRU binary.
unsafe { pruss.pru0.load_code(&m... | {
// Get a view of the PRU subsystem.
let mut pruss = match Pruss::new(&IntcConfig::new_populated()) {
Ok(p) => p,
Err(e) => match e {
prusst::Error::AlreadyInstantiated
=> panic!("You can't instantiate more than one `Pruss` object at a time."),
prusst::Er... | identifier_body |
barebone_blink.rs | //! Flash the BeagleBone USR1 LED 5 times at 2Hz.
//!
//! The PRU code notifies the host processor every time the LED is flashed by triggering Evtout0.
//! The 6-th event out is interpreted as a completion notification.
extern crate prusst;
use prusst::{Pruss, IntcConfig, Evtout, Sysevt};
use std::fs::File;
use std... | Ok(p) => p,
Err(e) => match e {
prusst::Error::AlreadyInstantiated
=> panic!("You can't instantiate more than one `Pruss` object at a time."),
prusst::Error::PermissionDenied
=> panic!("You do not have permission to access the PRU subsystem: \
... | fn main() {
// Get a view of the PRU subsystem.
let mut pruss = match Pruss::new(&IntcConfig::new_populated()) { | random_line_split |
barebone_blink.rs | //! Flash the BeagleBone USR1 LED 5 times at 2Hz.
//!
//! The PRU code notifies the host processor every time the LED is flashed by triggering Evtout0.
//! The 6-th event out is interpreted as a completion notification.
extern crate prusst;
use prusst::{Pruss, IntcConfig, Evtout, Sysevt};
use std::fs::File;
use std... | () {
// Get a view of the PRU subsystem.
let mut pruss = match Pruss::new(&IntcConfig::new_populated()) {
Ok(p) => p,
Err(e) => match e {
prusst::Error::AlreadyInstantiated
=> panic!("You can't instantiate more than one `Pruss` object at a time."),
prusst:... | main | identifier_name |
function_call.rs | use criterion::{black_box, criterion_group, criterion_main, Bencher, Criterion};
| use gluon::{
new_vm,
vm::{
api::{primitive, FunctionRef, Primitive},
thread::{Status, Thread},
},
ThreadExt,
};
// Benchmarks function calls
fn identity(b: &mut Bencher) {
let vm = new_vm();
let text = r#"
let id x = x
id
"#;
vm.load_script("id", text).unwrap();... | random_line_split | |
function_call.rs | use criterion::{black_box, criterion_group, criterion_main, Bencher, Criterion};
use gluon::{
new_vm,
vm::{
api::{primitive, FunctionRef, Primitive},
thread::{Status, Thread},
},
ThreadExt,
};
// Benchmarks function calls
fn identity(b: &mut Bencher) |
fn factorial(b: &mut Bencher) {
let vm = new_vm();
let text = r#"
let factorial n =
if n < 2
then 1
else n * factorial (n - 1)
factorial
"#;
vm.load_script("factorial", text).unwrap();
let mut factorial: FunctionRef<fn(i32) -> i32> = vm.get_global("factorial").unwra... | {
let vm = new_vm();
let text = r#"
let id x = x
id
"#;
vm.load_script("id", text).unwrap();
let mut id: FunctionRef<fn(i32) -> i32> = vm.get_global("id").unwrap();
b.iter(|| {
let result = id.call(20).unwrap();
black_box(result)
})
} | identifier_body |
function_call.rs | use criterion::{black_box, criterion_group, criterion_main, Bencher, Criterion};
use gluon::{
new_vm,
vm::{
api::{primitive, FunctionRef, Primitive},
thread::{Status, Thread},
},
ThreadExt,
};
// Benchmarks function calls
fn identity(b: &mut Bencher) {
let vm = new_vm();
let t... | (b: &mut Bencher) {
let vm = new_vm();
let text = r#"
let factorial a n =
if n < 2
then a
else factorial (a * n) (n - 1)
factorial 1
"#;
vm.load_script("factorial", text).unwrap();
let mut factorial: FunctionRef<fn(i32) -> i32> = vm.get_global("factorial").unwrap();
... | factorial_tail_call | identifier_name |
mod.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/. */
//! The implementation of the DOM.
//!
//! The DOM is comprised of interfaces (defined by specifications using
//... | pub mod mutationobserver;
pub mod mutationrecord;
pub mod namednodemap;
pub mod navigationpreloadmanager;
pub mod navigator;
pub mod navigatorinfo;
pub mod node;
pub mod nodeiterator;
pub mod nodelist;
pub mod offlineaudiocompletionevent;
pub mod offlineaudiocontext;
pub mod offscreencanvas;
pub mod offscreencanvasrend... | pub mod mouseevent; | random_line_split |
clone.rs | //! The `Clone` trait for types that cannot be 'implicitly copied'.
//!
//! In Rust, some simple types are "implicitly copyable" and when you
//! assign them or pass them as arguments, the receiver will get a copy,
//! leaving the original value in place. These types do not require
//! allocation to copy and do not hav... | ///
/// Types that are [`Copy`] should have a trivial implementation of `Clone`. More formally:
/// if `T: Copy`, `x: T`, and `y: &T`, then `let x = y.clone();` is equivalent to `let x = *y;`.
/// Manual implementations should be careful to uphold this invariant; however, unsafe code
/// must not rely on it to ensure m... | /// }
/// ```
///
/// ## How can I implement `Clone`? | random_line_split |
clone.rs | //! The `Clone` trait for types that cannot be 'implicitly copied'.
//!
//! In Rust, some simple types are "implicitly copyable" and when you
//! assign them or pass them as arguments, the receiver will get a copy,
//! leaving the original value in place. These types do not require
//! allocation to copy and do not hav... |
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T:?Sized> Clone for *const T {
#[inline]
fn clone(&self) -> Self {
*self
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T:?Sized> Clone for *mut T {
#[inline]
fn clone(&self) -> Se... | {
*self
} | identifier_body |
clone.rs | //! The `Clone` trait for types that cannot be 'implicitly copied'.
//!
//! In Rust, some simple types are "implicitly copyable" and when you
//! assign them or pass them as arguments, the receiver will get a copy,
//! leaving the original value in place. These types do not require
//! allocation to copy and do not hav... | <T: Clone +?Sized> {
_field: crate::marker::PhantomData<T>,
}
#[doc(hidden)]
#[allow(missing_debug_implementations)]
#[unstable(
feature = "derive_clone_copy",
reason = "deriving hack, should not be public",
issue = "none"
)]
pub struct AssertParamIsCopy<T: Copy +?Sized> {
_field: crate::marker::Pha... | AssertParamIsClone | identifier_name |
issue-53548.rs | // Regression test for #53548. The `Box<dyn Trait>` type below is
// expanded to `Box<dyn Trait +'static>`, but the generator "witness"
// that results is `for<'r> { Box<dyn Trait + 'r> }`. The WF code was
// encountering an ICE (when debug-assertions were enabled) and an
// unexpected compilation error (without debug-... | Box::new(static move || {
let store = Store::<Box<dyn Trait>> {
inner: Default::default(),
};
yield ();
});
} | random_line_split | |
issue-53548.rs | // Regression test for #53548. The `Box<dyn Trait>` type below is
// expanded to `Box<dyn Trait +'static>`, but the generator "witness"
// that results is `for<'r> { Box<dyn Trait + 'r> }`. The WF code was
// encountering an ICE (when debug-assertions were enabled) and an
// unexpected compilation error (without debug-... | () {
Box::new(static move || {
let store = Store::<Box<dyn Trait>> {
inner: Default::default(),
};
yield ();
});
}
| main | identifier_name |
issue-53548.rs | // Regression test for #53548. The `Box<dyn Trait>` type below is
// expanded to `Box<dyn Trait +'static>`, but the generator "witness"
// that results is `for<'r> { Box<dyn Trait + 'r> }`. The WF code was
// encountering an ICE (when debug-assertions were enabled) and an
// unexpected compilation error (without debug-... | {
Box::new(static move || {
let store = Store::<Box<dyn Trait>> {
inner: Default::default(),
};
yield ();
});
} | identifier_body | |
file.rs | use std::path::Path;
use std::fs::File;
use std::fs::OpenOptions;
use std::error::Error;
use std::io::prelude::*;
use std::io::BufReader;
use regex::Regex;
#[allow(unused_variables)]
pub fn write(pathstring: &str, content: &str) -> bool {
let path = Path::new(pathstring);
let mut file = match File::create(&path)... | {
let path = Path::new(pathstring);
let mut file;
if path.exists() {
file = match OpenOptions::new().write(true).append(true).open(&path) {
Err(why) => {panic!("couldn't create File: {}, File: {:?}", Error::description(&why), &path)}
Ok(file) => file,
};
} else {
file = match OpenOption... | identifier_body | |
file.rs | use std::path::Path;
use std::fs::File;
use std::fs::OpenOptions;
use std::error::Error;
use std::io::prelude::*;
use std::io::BufReader;
use regex::Regex;
#[allow(unused_variables)]
pub fn write(pathstring: &str, content: &str) -> bool {
let path = Path::new(pathstring);
let mut file = match File::create(&path)... | (path: &Path) -> String {
let mut content: String = String::new();
let mut file = match File::open(&path) {
Err(why) => {panic!("couldn't create File: {}, File: {:?}", Error::description(&why), &path)}
Ok(file) => file,
};
file.read_to_string(&mut content);
content
}
#[allow(unused_must_use)]
pub f... | read | identifier_name |
file.rs | use std::path::Path;
use std::fs::File;
use std::fs::OpenOptions;
use std::error::Error;
use std::io::prelude::*;
use std::io::BufReader; | pub fn write(pathstring: &str, content: &str) -> bool {
let path = Path::new(pathstring);
let mut file = match File::create(&path) {
Err(why) => {panic!("couldn't create File: {}, File: {:?}", Error::description(&why), &path)}
Ok(file) => file,
};
match file.write_all(content.as_bytes()) {
Err(_) ... | use regex::Regex;
#[allow(unused_variables)] | random_line_split |
cstore.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... |
pub fn get_used_link_args<'a>(&'a self) -> &'a RefCell<Vec<~str> > {
&self.used_link_args
}
pub fn add_extern_mod_stmt_cnum(&self,
emod_id: ast::NodeId,
cnum: ast::CrateNum) {
self.extern_mod_crate_map.borrow_mut().in... | {
for s in args.split(' ') {
self.used_link_args.borrow_mut().push(s.to_owned());
}
} | identifier_body |
cstore.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... | (&self) -> ast::CrateNum {
self.metas.borrow().len() as ast::CrateNum + 1
}
pub fn get_crate_data(&self, cnum: ast::CrateNum) -> Rc<crate_metadata> {
self.metas.borrow().get(&cnum).clone()
}
pub fn get_crate_hash(&self, cnum: ast::CrateNum) -> Svh {
let cdata = self.get_crate_d... | next_crate_num | identifier_name |
cstore.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... |
pub fn find_extern_mod_stmt_cnum(&self, emod_id: ast::NodeId)
-> Option<ast::CrateNum> {
self.extern_mod_crate_map.borrow().find(&emod_id).map(|x| *x)
}
}
impl crate_metadata {
pub fn data<'a>(&'a self) -> &'a [u8] { self.data.as_slice() }
pub fn crate_id(&... | emod_id: ast::NodeId,
cnum: ast::CrateNum) {
self.extern_mod_crate_map.borrow_mut().insert(emod_id, cnum);
} | random_line_split |
preserve.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 ... | (&self, cmt: cmt, base: cmt,
derefs: uint) -> bckres<PreserveCondition> {
if!self.root_managed_data {
// normally, there is a root_ub; the only time that this
// is none is when a boxed value is stored in an immutable
// location. In that case, we will te... | attempt_root | identifier_name |
preserve.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 ... |
/// Here, `cmt=*base` is always a deref of managed data (if
/// `derefs`!= 0, then an auto-deref). This routine determines
/// whether it is safe to MAKE cmt stable by rooting the pointer
/// `base`. We can only do the dynamic root if the desired
/// lifetime `self.scope_region` is a subset of `... | {
if self.bccx.is_subregion_of(self.scope_region, scope_ub) {
Ok(PcOk)
} else {
Err(bckerr {
cmt:cmt,
code:err_out_of_scope(scope_ub, self.scope_region)
})
}
} | identifier_body |
preserve.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 ... | // the corner case.
//
// Nonetheless, if you decide to optimize this case in the
// future, you need only adjust where the cat_discr()
// node appears to draw the line between what will be rooted
// in the *arm* vs the *match*.
let ... | random_line_split | |
preserve.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 ... | else {
self.attempt_root(cmt, base, derefs)
}
}
cat_discr(base, match_id) => {
// Subtle: in a match, we must ensure that each binding
// variable remains valid for the duration of the arm in
// which it appears, presuming that this ar... | {
let non_rooting_ctxt = PreserveCtxt {
root_managed_data: false,
..*self
};
match non_rooting_ctxt.preserve(base) {
Ok(PcOk) => {
Ok(PcOk)
}
Ok(PcIfPure(_)) ... | conditional_block |
sparkline.rs | use std::fmt;
pub struct Ascii {
min: f64,
max: f64,
data: Vec<f64>,
step: usize,
} | Self {
min,
max,
data,
step,
}
}
}
impl fmt::Display for Ascii {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let ticks = vec!['▁', '▂', '▃', '▄', '▅', '▆', '▇'];
let ticks_len = (ticks.len() - 1) as f64;
let spar... |
impl Ascii {
pub fn new(min: f64, max: f64, data: Vec<f64>, step: usize) -> Self { | random_line_split |
sparkline.rs | use std::fmt;
pub struct Ascii {
min: f64,
max: f64,
data: Vec<f64>,
step: usize,
}
impl Ascii {
pub fn new(min: f64, max: f64, data: Vec<f64>, step: usize) -> Self {
Self {
min,
max,
data,
step,
}
}
}
impl fmt::Display for Ascii... | ticks[i as usize]
})
.collect();
write!(f, "{}", sparkline)
}
}
#[test]
fn test_display() {
let s = Ascii {
min: 0.,
max: 1.,
data: vec![0.],
step: 2,
};
assert_eq!(format!("{}", s), "▁");
let s = Ascii {
min: 0.,
max... | i = (i / self.max).round();
}
| conditional_block |
sparkline.rs | use std::fmt;
pub struct Ascii {
min: f64,
max: f64,
data: Vec<f64>,
step: usize,
}
impl Ascii {
pub fn new(min: f64, max: f64, data: Vec<f64>, step: usize) -> Self {
Self {
min,
max,
data,
step,
}
}
}
impl fmt::Display for Ascii... | fn
test_display() {
let s = Ascii {
min: 0.,
max: 1.,
data: vec![0.],
step: 2,
};
assert_eq!(format!("{}", s), "▁");
let s = Ascii {
min: 0.,
max: 1.,
data: vec![0., 10.],
step: 2,
};
assert_eq!(format!("{}", s), "▁");
let s =... | {
let ticks = vec!['▁', '▂', '▃', '▄', '▅', '▆', '▇'];
let ticks_len = (ticks.len() - 1) as f64;
let sparkline: String = self
.data
.iter()
.step_by(self.step)
.map(|x| {
let mut i = ticks_len * (x - self.min);
if i ... | identifier_body |
sparkline.rs | use std::fmt;
pub struct Ascii {
min: f64,
max: f64,
data: Vec<f64>,
step: usize,
}
impl Ascii {
pub fn | (min: f64, max: f64, data: Vec<f64>, step: usize) -> Self {
Self {
min,
max,
data,
step,
}
}
}
impl fmt::Display for Ascii {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let ticks = vec!['▁', '▂', '▃', '▄', '▅', '▆', '▇'];
... | new | identifier_name |
main.rs | // Copyright (c) 2020 DDN. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
mod action;
mod command;
mod error;
mod graphql;
mod task;
mod timer;
use iml_manager_env::get_pool_limit;
use iml_postgres::get_db_pool;
use iml_rabbit::{self, creat... |
let addr = iml_manager_env::get_iml_api_addr();
let conf = Conf {
allow_anonymous_read: iml_manager_env::get_allow_anonymous_read(),
build: iml_manager_env::get_build(),
version: iml_manager_env::get_version(),
exa_version: iml_manager_env::get_exa_version(),
is_release... | iml_tracing::init(); | random_line_split |
main.rs | // Copyright (c) 2020 DDN. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
mod action;
mod command;
mod error;
mod graphql;
mod task;
mod timer;
use iml_manager_env::get_pool_limit;
use iml_postgres::get_db_pool;
use iml_rabbit::{self, creat... | let conn_filter = create_connection_filter(rabbit_pool);
let pg_pool = get_db_pool(get_pool_limit().unwrap_or(DEFAULT_POOL_LIMIT)).await?;
let pg_pool_2 = pg_pool.clone();
let db_pool_filter = warp::any().map(move || pg_pool.clone());
let schema = Arc::new(graphql::Schema::new(
graphql::Qu... | {
iml_tracing::init();
let addr = iml_manager_env::get_iml_api_addr();
let conf = Conf {
allow_anonymous_read: iml_manager_env::get_allow_anonymous_read(),
build: iml_manager_env::get_build(),
version: iml_manager_env::get_version(),
exa_version: iml_manager_env::get_exa_ve... | identifier_body |
main.rs | // Copyright (c) 2020 DDN. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
mod action;
mod command;
mod error;
mod graphql;
mod task;
mod timer;
use iml_manager_env::get_pool_limit;
use iml_postgres::get_db_pool;
use iml_rabbit::{self, creat... | () -> Result<(), Box<dyn std::error::Error>> {
iml_tracing::init();
let addr = iml_manager_env::get_iml_api_addr();
let conf = Conf {
allow_anonymous_read: iml_manager_env::get_allow_anonymous_read(),
build: iml_manager_env::get_build(),
version: iml_manager_env::get_version(),
... | main | identifier_name |
relocation.rs | use crate::error;
use scroll::{IOread, IOwrite, Pread, Pwrite, SizeWith};
/// Size of a single COFF relocation.
pub const COFF_RELOCATION_SIZE: usize = 10;
// x86 relocations.
/// The relocation is ignored.
pub const IMAGE_REL_I386_ABSOLUTE: u16 = 0x0000; | /// Not supported.
pub const IMAGE_REL_I386_REL16: u16 = 0x0002;
/// The target's 32-bit VA.
pub const IMAGE_REL_I386_DIR32: u16 = 0x0006;
/// The target's 32-bit RVA.
pub const IMAGE_REL_I386_DIR32NB: u16 = 0x0007;
/// Not supported.
pub const IMAGE_REL_I386_SEG12: u16 = 0x0009;
/// The 16-bit section index of the sec... | /// Not supported.
pub const IMAGE_REL_I386_DIR16: u16 = 0x0001; | random_line_split |
relocation.rs | use crate::error;
use scroll::{IOread, IOwrite, Pread, Pwrite, SizeWith};
/// Size of a single COFF relocation.
pub const COFF_RELOCATION_SIZE: usize = 10;
// x86 relocations.
/// The relocation is ignored.
pub const IMAGE_REL_I386_ABSOLUTE: u16 = 0x0000;
/// Not supported.
pub const IMAGE_REL_I386_DIR16: u16 = 0x00... |
}
| {
if self.offset >= self.relocations.len() {
None
} else {
Some(
self.relocations
.gread_with(&mut self.offset, scroll::LE)
.unwrap(),
)
}
} | identifier_body |
relocation.rs | use crate::error;
use scroll::{IOread, IOwrite, Pread, Pwrite, SizeWith};
/// Size of a single COFF relocation.
pub const COFF_RELOCATION_SIZE: usize = 10;
// x86 relocations.
/// The relocation is ignored.
pub const IMAGE_REL_I386_ABSOLUTE: u16 = 0x0000;
/// Not supported.
pub const IMAGE_REL_I386_DIR16: u16 = 0x00... | (&mut self) -> Option<Self::Item> {
if self.offset >= self.relocations.len() {
None
} else {
Some(
self.relocations
.gread_with(&mut self.offset, scroll::LE)
.unwrap(),
)
}
}
}
| next | identifier_name |
relocation.rs | use crate::error;
use scroll::{IOread, IOwrite, Pread, Pwrite, SizeWith};
/// Size of a single COFF relocation.
pub const COFF_RELOCATION_SIZE: usize = 10;
// x86 relocations.
/// The relocation is ignored.
pub const IMAGE_REL_I386_ABSOLUTE: u16 = 0x0000;
/// Not supported.
pub const IMAGE_REL_I386_DIR16: u16 = 0x00... | else {
Some(
self.relocations
.gread_with(&mut self.offset, scroll::LE)
.unwrap(),
)
}
}
}
| {
None
} | conditional_block |
main.rs | extern crate rand;
use std::io;
use std::io::Write;
use std::cmp::Ordering;
use rand::Rng;
fn main() | Ordering::Less => {
println!("{} ist zu klein, versuch's nochmal!\n", guess);
},
Ordering::Greater => {
println!("{} ist zu gross, versuch's nochmal!\n", guess);
},
Ordering::Equal => {
println!("----------------... | {
println!("Zahlenraten!");
println!("============");
let secret = rand::thread_rng().gen_range(1, 101);
//println!("Die Geheimzahl lautet: {}", secret);
loop {
print!("Geheimzahl eingeben (< 100): ");
io::stdout().flush().ok().expect("Konnte stdout nicht flushen.");
let mu... | identifier_body |
main.rs | extern crate rand;
use std::io;
use std::io::Write;
use std::cmp::Ordering;
use rand::Rng;
fn main() {
println!("Zahlenraten!");
println!("============");
let secret = rand::thread_rng().gen_range(1, 101);
//println!("Die Geheimzahl lautet: {}", secret);
loop {
print!("Geheimzahl eingeb... | ,
Ordering::Greater => {
println!("{} ist zu gross, versuch's nochmal!\n", guess);
},
Ordering::Equal => {
println!("-------------------");
println!("\\o/ Gewonnen! \\o/");
println!("-------------------");
... | {
println!("{} ist zu klein, versuch's nochmal!\n", guess);
} | conditional_block |
main.rs | extern crate rand;
use std::io;
use std::io::Write;
use std::cmp::Ordering;
use rand::Rng;
fn main() {
println!("Zahlenraten!");
println!("============");
let secret = rand::thread_rng().gen_range(1, 101);
//println!("Die Geheimzahl lautet: {}", secret);
loop {
print!("Geheimzahl eingeb... | println!("-------------------");
break;
},
}
}
} | println!("-------------------");
println!("\\o/ Gewonnen! \\o/"); | random_line_split |
main.rs | extern crate rand;
use std::io;
use std::io::Write;
use std::cmp::Ordering;
use rand::Rng;
fn | () {
println!("Zahlenraten!");
println!("============");
let secret = rand::thread_rng().gen_range(1, 101);
//println!("Die Geheimzahl lautet: {}", secret);
loop {
print!("Geheimzahl eingeben (< 100): ");
io::stdout().flush().ok().expect("Konnte stdout nicht flushen.");
let... | main | identifier_name |
autoderef-method-twice.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 ... | (self: Box<usize>) -> usize { *self * 2 }
}
pub fn main() {
let x: Box<Box<_>> = box box 3;
assert_eq!(x.double(), 6);
}
| double | identifier_name |
autoderef-method-twice.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 x: Box<Box<_>> = box box 3;
assert_eq!(x.double(), 6);
} | identifier_body | |
aarch64_unknown_netbsd.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 ... | () -> TargetResult {
let mut base = super::netbsd_base::opts();
base.max_atomic_width = Some(128);
base.abi_blacklist = super::arm_base::abi_blacklist();
Ok(Target {
llvm_target: "aarch64-unknown-netbsd".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64... | target | identifier_name |
aarch64_unknown_netbsd.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 ... | {
let mut base = super::netbsd_base::opts();
base.max_atomic_width = Some(128);
base.abi_blacklist = super::arm_base::abi_blacklist();
Ok(Target {
llvm_target: "aarch64-unknown-netbsd".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
... | identifier_body | |
aarch64_unknown_netbsd.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 ... | pub fn target() -> TargetResult {
let mut base = super::netbsd_base::opts();
base.max_atomic_width = Some(128);
base.abi_blacklist = super::arm_base::abi_blacklist();
Ok(Target {
llvm_target: "aarch64-unknown-netbsd".to_string(),
target_endian: "little".to_string(),
target_point... | use spec::{LinkerFlavor, Target, TargetResult};
| random_line_split |
running-with-no-runtime.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 ... | #[start]
fn start(argc: isize, argv: *const *const u8) -> isize {
if argc > 1 {
unsafe {
match **argv.offset(1) as char {
'1' => {}
'2' => println!("foo"),
'3' => assert!(thread::catch_panic(|| {}).is_ok()),
'4' => assert!(thread::c... | use std::thread;
use std::str;
| random_line_split |
running-with-no-runtime.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 ... | };
let me = String::from_utf8(args[0].to_vec()).unwrap();
pass(Command::new(&me).arg("1").output().unwrap());
pass(Command::new(&me).arg("2").output().unwrap());
pass(Command::new(&me).arg("3").output().unwrap());
pass(Command::new(&me).arg("4").output().unwrap());
pass(Command::new(&me).ar... | {
if argc > 1 {
unsafe {
match **argv.offset(1) as char {
'1' => {}
'2' => println!("foo"),
'3' => assert!(thread::catch_panic(|| {}).is_ok()),
'4' => assert!(thread::catch_panic(|| panic!()).is_err()),
'5' => assert... | identifier_body |
running-with-no-runtime.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 ... | (output: Output) {
if!output.status.success() {
println!("{:?}", str::from_utf8(&output.stdout));
println!("{:?}", str::from_utf8(&output.stderr));
}
}
| pass | identifier_name |
mod.rs | // Copyright 2015 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 ... | } | random_line_split | |
mod.rs | // Copyright 2015 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 Drop for Socket {
fn drop(&mut self) {
unsafe {
let _ = libc::close(self.fd);
}
}
}
| {
Socket { fd: fd }
} | identifier_body |
mod.rs | // Copyright 2015 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 ... | (self) -> TcpStream {
unsafe { TcpStream::from_raw_fd(self.into_fd()) }
}
pub fn into_udp_socket(self) -> UdpSocket {
unsafe { UdpSocket::from_raw_fd(self.into_fd()) }
}
}
impl ::FromInner for Socket {
type Inner = c_int;
fn from_inner(fd: c_int) -> Socket {
Socket { fd: fd... | into_tcp_stream | identifier_name |
mode.rs | // Copyright 2015-2017 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 lat... | (mode: Mode) -> Self {
match mode {
Mode::Off => ClientMode::Off,
Mode::Dark(timeout) => ClientMode::Dark(Duration::from_secs(timeout)),
Mode::Passive(timeout, alarm) => ClientMode::Passive(Duration::from_secs(timeout), Duration::from_secs(alarm)),
Mode::Active => ClientMode::Active,
}
}
}
| from | identifier_name |
mode.rs | // Copyright 2015-2017 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 lat... | Mode::Passive(timeout, alarm) => ClientMode::Passive(Duration::from_secs(timeout), Duration::from_secs(alarm)),
Mode::Active => ClientMode::Active,
}
}
} | Mode::Off => ClientMode::Off,
Mode::Dark(timeout) => ClientMode::Dark(Duration::from_secs(timeout)), | random_line_split |
mode.rs | // Copyright 2015-2017 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 lat... |
}
| {
match mode {
Mode::Off => ClientMode::Off,
Mode::Dark(timeout) => ClientMode::Dark(Duration::from_secs(timeout)),
Mode::Passive(timeout, alarm) => ClientMode::Passive(Duration::from_secs(timeout), Duration::from_secs(alarm)),
Mode::Active => ClientMode::Active,
}
} | identifier_body |
fixed_bug_11.rs | /*!
* # Expected behaviour:
* The top cube will fall asleep while the bottom cube goes right at constant speed.
*
* # Symptoms:
* Bothe cube fall asleep at some point.
*
* # Cause:
* There was no way of customizing the deactivation threshold.
*
* # Solution:
* Rigid bodies now have a `set_deactivation_thresh... | */
rb.set_deactivation_threshold(Some(0.5));
rb.append_translation(&Vec2::new(0.0, 3.0));
world.add_body(rb);
/*
* Set up the testbed.
*/
let mut testbed = Testbed::new(world);
testbed.run();
}
| {
/*
* World
*/
let mut world = World::new();
world.set_gravity(Vec2::new(0.0, 0.0));
/*
* Create the box that will be deactivated.
*/
let rad = 1.0;
let geom = Cuboid::new(Vec2::new(rad, rad));
let mut rb = RigidBody::new_dynamic(geom, 1.0, 0.3, 0.5);
rb.set_l... | identifier_body |
fixed_bug_11.rs | /*!
* # Expected behaviour:
* The top cube will fall asleep while the bottom cube goes right at constant speed.
*
* # Symptoms:
* Bothe cube fall asleep at some point.
*
* # Cause:
* There was no way of customizing the deactivation threshold.
*
* # Solution:
* Rigid bodies now have a `set_deactivation_thresh... | /*
* Create the box that will not be deactivated.
*/
rb.set_deactivation_threshold(Some(0.5));
rb.append_translation(&Vec2::new(0.0, 3.0));
world.add_body(rb);
/*
* Set up the testbed.
*/
let mut testbed = Testbed::new(world);
testbed.run();
} | random_line_split | |
fixed_bug_11.rs | /*!
* # Expected behaviour:
* The top cube will fall asleep while the bottom cube goes right at constant speed.
*
* # Symptoms:
* Bothe cube fall asleep at some point.
*
* # Cause:
* There was no way of customizing the deactivation threshold.
*
* # Solution:
* Rigid bodies now have a `set_deactivation_thresh... | () {
/*
* World
*/
let mut world = World::new();
world.set_gravity(Vec2::new(0.0, 0.0));
/*
* Create the box that will be deactivated.
*/
let rad = 1.0;
let geom = Cuboid::new(Vec2::new(rad, rad));
let mut rb = RigidBody::new_dynamic(geom, 1.0, 0.3, 0.5);
rb.se... | main | identifier_name |
pipe.rs | // Copyright 2015 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 raw(&self) -> libc::c_int { self.0.raw() }
pub fn fd(&self) -> &FileDesc { &self.0 }
}
| {
self.0.write(buf)
} | identifier_body |
pipe.rs | // Copyright 2015 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 {
Err(io::Error::last_os_error())
}
}
impl AnonPipe {
pub fn from_fd(fd: libc::c_int) -> AnonPipe {
let fd = FileDesc::new(fd);
fd.set_cloexec();
AnonPipe(fd)
}
pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> {
self.0.read(buf)
}
pub fn wr... | {
Ok((AnonPipe::from_fd(fds[0]), AnonPipe::from_fd(fds[1])))
} | conditional_block |
pipe.rs | // Copyright 2015 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 ... | (fd: libc::c_int) -> AnonPipe {
let fd = FileDesc::new(fd);
fd.set_cloexec();
AnonPipe(fd)
}
pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> {
self.0.read(buf)
}
pub fn write(&self, buf: &[u8]) -> io::Result<usize> {
self.0.write(buf)
}
pub fn r... | from_fd | identifier_name |
pipe.rs | // Copyright 2015 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 raw(&self) -> libc::c_int { self.0.raw() }
pub fn fd(&self) -> &FileDesc { &self.0 }
} | random_line_split | |
ignore-all-the-things.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 ... | {a: int, b: int, c: int, d: int}
pub fn main() {
let Foo(..) = Foo(5, 5, 5, 5);
let Foo(..) = Foo(5, 5, 5, 5);
let Bar{..} = Bar{a: 5, b: 5, c: 5, d: 5};
//let (..) = (5, 5, 5, 5);
//let Foo(a, b,..) = Foo(5, 5, 5, 5);
//let Foo(.., d) = Foo(5, 5, 5, 5);
//let (a, b,..) = (5, 5, 5, 5);
... | Bar | identifier_name |
ignore-all-the-things.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 ... |
}
match [5, 5, 5, 5] {
[a,.., b] => { }
}
match [5, 5, 5] {
[..] => { }
}
match [5, 5, 5] {
[a,..] => { }
}
match [5, 5, 5] {
[.., a] => { }
}
match [5, 5, 5] {
[a,.., b] => { }
}
}
| { } | conditional_block |
ignore-all-the-things.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 ... | }
} | random_line_split | |
scribe.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use std::num::NonZeroU64;
use anyhow::anyhow;
use bookmarks_types::BookmarkName;
use changesets::ChangesetsRef;
use chrono::Utc;
use conte... | repo: &(impl RepoIdentityRef + ChangesetsRef),
bookmark: Option<&BookmarkName>,
changesets_and_changed_files_count: Vec<ScribeCommitInfo>,
commit_scribe_category: Option<&str>,
) {
let queue = match commit_scribe_category {
Some(category) if!category.is_empty() => {
LogToScribe::... | random_line_split | |
scribe.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use std::num::NonZeroU64;
use anyhow::anyhow;
use bookmarks_types::BookmarkName;
use changesets::ChangesetsRef;
use chrono::Utc;
use conte... |
}
pub async fn log_commit_to_scribe(
ctx: &CoreContext,
category: &str,
container: &(impl RepoIdentityRef + ChangesetsRef),
changeset: &BonsaiChangeset,
bubble: Option<BubbleId>,
) {
let changeset_id = changeset.get_changeset_id();
let changed_files = ChangedFilesInfo::new(changeset);
... | {
ctx.scuba()
.clone()
.log_with_msg("Failed to log pushed commits", Some(format!("{}", err)));
} | conditional_block |
scribe.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use std::num::NonZeroU64;
use anyhow::anyhow;
use bookmarks_types::BookmarkName;
use changesets::ChangesetsRef;
use chrono::Utc;
use conte... | (
ctx: &CoreContext,
category: &str,
container: &(impl RepoIdentityRef + ChangesetsRef),
changeset: &BonsaiChangeset,
bubble: Option<BubbleId>,
) {
let changeset_id = changeset.get_changeset_id();
let changed_files = ChangedFilesInfo::new(changeset);
log_commits_to_scribe_raw(
c... | log_commit_to_scribe | identifier_name |
lib.rs | fn compute_kmp_table(word: &String) -> Vec<i32> {
let mut table : Vec<i32> = vec![0; word.len()];
let mut pos = 2;
let mut cnd = 0;
let word_chars : Vec<char> = word.chars().collect::<Vec<char>>();
table[0] = -1;
table[1] = 0;
while pos < word.len() {
if word_chars[pos - 1] ==... | () {
let word : String = "ABCDABD".to_string();
let text : String = "ABC ABCDAB ABCDABCDABDE".to_string();
let expected_res : usize = 15;
let res : usize = kmp_serch(&word, &text);
assert_eq!(res, expected_res);
} | kmp_serch_1 | identifier_name |
lib.rs | fn compute_kmp_table(word: &String) -> Vec<i32> {
let mut table : Vec<i32> = vec![0; word.len()];
let mut pos = 2;
let mut cnd = 0;
let word_chars : Vec<char> = word.chars().collect::<Vec<char>>();
table[0] = -1;
table[1] = 0;
while pos < word.len() {
if word_chars[pos - 1] ==... | }
table
}
fn kmp_serch(word: & String, text: & String) -> usize {
let mut m : usize = 0;
let mut i : usize = 0;
let table : Vec<i32> = compute_kmp_table(&word);
let text_len : usize = text.len();
let word_len : usize = word.len();
let word_chars : Vec<char> = word.chars().collect::<Ve... | cnd = (table[cnd]) as usize;
} else {
table[pos] = 0;
pos += 1;
} | random_line_split |
lib.rs | fn compute_kmp_table(word: &String) -> Vec<i32> {
let mut table : Vec<i32> = vec![0; word.len()];
let mut pos = 2;
let mut cnd = 0;
let word_chars : Vec<char> = word.chars().collect::<Vec<char>>();
table[0] = -1;
table[1] = 0;
while pos < word.len() {
if word_chars[pos - 1] ==... | } else {
i = 0;
m += 1;
}
}
}
text_len // no match found
}
#[test]
fn compute_kmp_table_test_1() {
let word : String = "ABCDABD".to_string();
let expected_res : Vec<i32> = vec![-1, 0, 0, 0, 0, 1, 2];
let res : Vec<i32> = compute_kmp_... | {
let mut m : usize = 0;
let mut i : usize = 0;
let table : Vec<i32> = compute_kmp_table(&word);
let text_len : usize = text.len();
let word_len : usize = word.len();
let word_chars : Vec<char> = word.chars().collect::<Vec<char>>();
let text_chars : Vec<char> = text.chars().collect::<Vec<ch... | identifier_body |
where_clauses_in_functions.rs | // Copyright 2017 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 ... | {} | identifier_body | |
where_clauses_in_functions.rs | // Copyright 2017 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 ... |
// compile-flags: -Zborrowck=mir
#![allow(dead_code)]
fn foo<'a, 'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32)
where
'a: 'b,
{
(x, y)
}
fn bar<'a, 'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {
foo(x, y)
//~^ ERROR unsatisfied lifetime constraints
}
fn main() {} | // option. This file may not be copied, modified, or distributed
// except according to those terms. | random_line_split |
where_clauses_in_functions.rs | // Copyright 2017 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, 'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32)
where
'a: 'b,
{
(x, y)
}
fn bar<'a, 'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {
foo(x, y)
//~^ ERROR unsatisfied lifetime constraints
}
fn main() {}
| foo | identifier_name |
lib.rs | //! Asynchronous sinks
//!
//! This crate contains the `Sink` trait which allows values to be sent
//! asynchronously.
#![cfg_attr(not(feature = "std"), no_std)]
#![warn(missing_debug_implementations, missing_docs, rust_2018_idioms, unreachable_pub)]
// It cannot be included in the published code because this lints ha... | (self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
}
impl<T> Sink<T> for alloc::collections::VecDeque<T> {
type Error = Infallible;
fn poll_ready(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
... | poll_close | identifier_name |
lib.rs | //! Asynchronous sinks
//!
//! This crate contains the `Sink` trait which allows values to be sent
//! asynchronously.
#![cfg_attr(not(feature = "std"), no_std)]
#![warn(missing_debug_implementations, missing_docs, rust_2018_idioms, unreachable_pub)]
// It cannot be included in the published code because this lints ha... | ///
/// Implementations of `poll_ready` and `start_send` will usually involve
/// flushing behind the scenes in order to make room for new messages.
/// It is only necessary to call `poll_flush` if you need to guarantee that
/// *all* of the items placed into the `Sink` have been sent.
///
/... | /// underlying object takes place asynchronously. **You *must* use
/// `poll_flush` or `poll_close` in order to guarantee completion of a
/// send**. | random_line_split |
lib.rs | //! Asynchronous sinks
//!
//! This crate contains the `Sink` trait which allows values to be sent
//! asynchronously.
#![cfg_attr(not(feature = "std"), no_std)]
#![warn(missing_debug_implementations, missing_docs, rust_2018_idioms, unreachable_pub)]
// It cannot be included in the published code because this lints ha... |
fn start_send(self: Pin<&mut Self>, item: T) -> Result<(), Self::Error> {
// TODO: impl<T> Unpin for Vec<T> {}
unsafe { self.get_unchecked_mut() }.push(item);
Ok(())
}
fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>>... | {
Poll::Ready(Ok(()))
} | identifier_body |
small_vector.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... | OneIterator(..) => {
let mut replacement = ZeroIterator;
mem::swap(&mut self.repr, &mut replacement);
match replacement {
OneIterator(v) => Some(v),
_ => unreachable!()
}
}
ManyIte... | ZeroIterator => None, | random_line_split |
small_vector.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... |
#[test]
fn test_expect_one_one() {
assert_eq!(1, SmallVector::one(1).expect_one(""));
assert_eq!(1, SmallVector::many(vec!(1)).expect_one(""));
}
}
| {
SmallVector::many(vec!(1, 2)).expect_one("");
} | identifier_body |
small_vector.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... | () {
assert_eq!(1, SmallVector::one(1).expect_one(""));
assert_eq!(1, SmallVector::many(vec!(1)).expect_one(""));
}
}
| test_expect_one_one | identifier_name |
taskstore.rs | //
// imag - the personal information management suite for the commandline
// Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the ... | <R: BufRead>(&'a self, mut r: R) -> Result<FileLockEntry<'a>> {
let mut line = String::new();
r.read_line(&mut line).chain_err(|| TEK::UTF8Error)?;
self.retrieve_task_from_string(line)
}
/// Retrieve a task from a String. The String is expected to contain the JSON-representation of
... | retrieve_task_from_import | identifier_name |
taskstore.rs | //
// imag - the personal information management suite for the commandline
// Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the ... |
/// Get a task from an UUID.
///
/// If there is no task with this UUID, this returns `Ok(None)`.
fn get_task_from_uuid(&'a self, uuid: Uuid) -> Result<Option<FileLockEntry<'a>>> {
ModuleEntryPath::new(format!("taskwarrior/{}", uuid))
.into_storeid()
.and_then(|store_id| ... | {
import_task(s.as_str())
.map_err(|_| TE::from_kind(TEK::ImportError))
.map(|t| t.uuid().clone())
.and_then(|uuid| self.get_task_from_uuid(uuid))
.and_then(|o| match o {
None => Ok(Err(s)),
Some(t) => Ok(Ok(t)),
})
... | identifier_body |
taskstore.rs | //
// imag - the personal information management suite for the commandline
// Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the ... | use libimagstore::storeid::{IntoStoreId, StoreIdIterator};
use module_path::ModuleEntryPath;
use error::TodoErrorKind as TEK;
use error::TodoError as TE;
use error::Result;
use error::ResultExt;
/// Task struct containing a `FileLockEntry`
pub trait TaskStore<'a> {
fn import_task_from_reader<R: BufRead>(&'a self,... | use task_hookrs::task::Task as TTask;
use task_hookrs::import::{import_task, import_tasks};
use libimagstore::store::{FileLockEntry, Store}; | random_line_split |
simple.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 ... |
fn maybe_yield(~self, _cur_task: ~Task) { fail!() }
fn spawn_sibling(~self, _cur_task: ~Task, _opts: TaskOpts, _f: proc()) {
fail!()
}
fn local_io<'a>(&'a mut self) -> Option<rtio::LocalIo<'a>> { None }
fn stack_bounds(&self) -> (uint, uint) { fail!() }
fn wrap(~self) -> ~Any { fail!() ... | { fail!() } | identifier_body |
simple.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 ... | (~self) -> ~Any { fail!() }
}
pub fn task() -> ~Task {
let mut task = ~Task::new();
task.put_runtime(~SimpleTask {
lock: LittleLock::new(),
awoken: false,
} as ~Runtime);
return task;
}
| wrap | identifier_name |
simple.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 ... | impl Runtime for SimpleTask {
// Implement the simple tasks of descheduling and rescheduling, but only in
// a simple number of cases.
fn deschedule(mut ~self, times: uint, mut cur_task: ~Task,
f: |BlockedTask| -> Result<(), BlockedTask>) {
assert!(times == 1);
let me = &m... | random_line_split | |
main.rs | use std::rc::Rc;
fn main() {
println!("Rust ownership system achieves memory safety");
println!("ownership, borrowing and lifetimes");
// META
// Rust focus: speed & safety
// through zero-cost abstractions
// ownership system at compile time | // {
// int *x = malloc(sizeof(int));
// *x = 5;
// free(x);
// }
// malloc allocates some memory, free deallocates the memory.
// thus bookkeeping about allocating the right amount of memory.
// Rust combines these 2 aspects of memory allocation into concept
// called o... |
// Fighting with the borrow checker
// programmer mental model mismatch with actual Rust rules
// Tracking memory allocations & deallocations | random_line_split |
main.rs | use std::rc::Rc;
fn main() {
println!("Rust ownership system achieves memory safety");
println!("ownership, borrowing and lifetimes");
// META
// Rust focus: speed & safety
// through zero-cost abstractions
// ownership system at compile time
// Fighting with the borrow checker
// pro... | {
name: String,
}
struct Wheel {
size: i32,
owner: Rc<Car>,
}
{
let car = Car { name: "MB".to_string() };
let car_owner = Rc::new(car);
for _ in 0..4 {
Wheel { size: 360, owner: car_owner.clone() };
}
}
// We can't do this ... | Car | identifier_name |
main.rs | use std::rc::Rc;
fn main() {
println!("Rust ownership system achieves memory safety");
println!("ownership, borrowing and lifetimes");
// META
// Rust focus: speed & safety
// through zero-cost abstractions
// ownership system at compile time
// Fighting with the borrow checker
// pro... |
// Rust: 'lifetime elision' which allows not to write
// lifetimes in certain circumstances.
//
// lifetime1 - without eliding lifetimes
fn lifetime2<'a>(num: &'a mut i32) {
*num += 1
}
// 'a is called a lifetime
// lifetime2<'a> - declares one lifetime, it is possible to specif... | {
*num += 1
} | identifier_body |
day1.rs | const DIRECTIONS: &'static str =
"R4, R5, L5, L5, L3, R2, R1, R1, L5, R5, R2, L1, L3, L4, R3, L1, L1, R2, R3, R3, R1, L3, L5, \
R3, R1, L1, R1, R2, L1, L4, L5, R4, R2, L192, R5, L2, R53, R1, L5, R73, R5, L5, R186, L3, \
L2, R1, R3, L3, L3, R1, L4, L2, R3, L5, R4, R3, R1, L1, R5, R2, R1, R1, R1, R3, R2, L1... | else { (vy2, vy1) };
if (vx > hx1 && vx < hx2) && (hy > vy1 && hy < vy2) {
println!("({},{})", vx, hy);
Some(Point { x: vx, y: hy })
} else {
None
}
}
fn is_parallel(&self, other: &Line) -> bool {
(self.is_horizontal() && other.is_horizontal... | { (vy1, vy2) } | conditional_block |
day1.rs | const DIRECTIONS: &'static str =
"R4, R5, L5, L5, L3, R2, R1, R1, L5, R5, R2, L1, L3, L4, R3, L1, L1, R2, R3, R3, R1, L3, L5, \
R3, R1, L1, R1, R2, L1, L4, L5, R4, R2, L192, R5, L2, R53, R1, L5, R73, R5, L5, R186, L3, \
L2, R1, R3, L3, L3, R1, L4, L2, R3, L5, R4, R3, R1, L1, R5, R2, R1, R1, R1, R3, R2, L1... | (self.is_horizontal() && other.is_horizontal()) ||
(self.is_vertical() && other.is_vertical())
}
fn is_horizontal(&self) -> bool {
self.start.y == self.end.y
}
fn is_vertical(&self) -> bool {
self.start.x == self.end.x
}
}
pub fn main() {
let mut path = Vec::ne... |
fn is_parallel(&self, other: &Line) -> bool { | random_line_split |
day1.rs | const DIRECTIONS: &'static str =
"R4, R5, L5, L5, L3, R2, R1, R1, L5, R5, R2, L1, L3, L4, R3, L1, L1, R2, R3, R3, R1, L3, L5, \
R3, R1, L1, R1, R2, L1, L4, L5, R4, R2, L192, R5, L2, R53, R1, L5, R73, R5, L5, R186, L3, \
L2, R1, R3, L3, L3, R1, L4, L2, R3, L5, R4, R3, R1, L1, R5, R2, R1, R1, R1, R3, R2, L1... |
}
pub fn main() {
let mut path = Vec::new();
let mut pos = Point { x: 0, y: 0 };
let mut prev_pos;
let mut intersect = None;
let mut facing = N;
let dirs = DIRECTIONS.split(", ");
for d in dirs {
prev_pos = pos;
let mut x = d.chars();
let turn = x.next().unwrap();... | {
self.start.x == self.end.x
} | identifier_body |
day1.rs | const DIRECTIONS: &'static str =
"R4, R5, L5, L5, L3, R2, R1, R1, L5, R5, R2, L1, L3, L4, R3, L1, L1, R2, R3, R3, R1, L3, L5, \
R3, R1, L1, R1, R2, L1, L4, L5, R4, R2, L192, R5, L2, R53, R1, L5, R73, R5, L5, R186, L3, \
L2, R1, R3, L3, L3, R1, L4, L2, R3, L5, R4, R3, R1, L1, R5, R2, R1, R1, R1, R3, R2, L1... | (&self) -> bool {
self.start.y == self.end.y
}
fn is_vertical(&self) -> bool {
self.start.x == self.end.x
}
}
pub fn main() {
let mut path = Vec::new();
let mut pos = Point { x: 0, y: 0 };
let mut prev_pos;
let mut intersect = None;
let mut facing = N;
let dirs = DI... | is_horizontal | identifier_name |
raw.rs | // Copyright 2015 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 st_dev: dev_t,
pub st_mode: mode_t,
pub st_nlink: nlink_t,
pub st_ino: ino_t,
pub st_uid: uid_t,
pub st_gid: gid_t,
pub st_rdev: dev_t,
pub st_atime: time_t,
pub st_atime_nsec: c_long,
pub st_mtime: time_t,
pub st_mtime_nsec: c_long,
pub st_ctime: time_t,
pub s... | stat | identifier_name |
raw.rs | // Copyright 2015 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 ... | #[repr(C)]
pub struct stat {
pub st_dev: dev_t,
pub st_mode: mode_t,
pub st_nlink: nlink_t,
pub st_ino: ino_t,
pub st_uid: uid_t,
pub st_gid: gid_t,
pub st_rdev: dev_t,
pub st_atime: time_t,
pub st_atime_nsec: c_long,
pub st_mtime: time_t,
pub st_mtime_nsec: c_long,
pub s... | random_line_split | |
rdynload.rs | // automatically generated by rust-bindgen
use super::boolean::*;
#[allow(dead_code)]
const SINGLESXP: u32 = 302;
#[allow(non_camel_case_types)]
pub type DL_FUNC = ::std::option::Option<extern "C" fn() -> *mut ::libc::c_void>;
#[allow(non_camel_case_types)]
pub type R_NativePrimitiveArgType = ::libc::c_uint;
#[allow(... |
}
impl ::std::default::Default for R_CMethodDef {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
#[allow(non_camel_case_types)]
pub type R_FortranMethodDef = R_CMethodDef;
#[repr(C)]
#[derive(Copy)]
#[allow(non_snake_case)]
pub struct R_CallMethodDef {
pub name: *const ::libc::c_char,
... | {
*self
} | identifier_body |
rdynload.rs | // automatically generated by rust-bindgen
use super::boolean::*;
#[allow(dead_code)]
const SINGLESXP: u32 = 302;
#[allow(non_camel_case_types)]
pub type DL_FUNC = ::std::option::Option<extern "C" fn() -> *mut ::libc::c_void>;
#[allow(non_camel_case_types)]
pub type R_NativePrimitiveArgType = ::libc::c_uint;
#[allow(... | }
}
#[allow(non_camel_case_types)]
pub type R_FortranMethodDef = R_CMethodDef;
#[repr(C)]
#[derive(Copy)]
#[allow(non_snake_case)]
pub struct R_CallMethodDef {
pub name: *const ::libc::c_char,
pub fun: DL_FUNC,
pub numArgs: ::libc::c_int,
}
impl ::std::clone::Clone for R_CallMethodDef {
fn clone(&s... | random_line_split | |
rdynload.rs | // automatically generated by rust-bindgen
use super::boolean::*;
#[allow(dead_code)]
const SINGLESXP: u32 = 302;
#[allow(non_camel_case_types)]
pub type DL_FUNC = ::std::option::Option<extern "C" fn() -> *mut ::libc::c_void>;
#[allow(non_camel_case_types)]
pub type R_NativePrimitiveArgType = ::libc::c_uint;
#[allow(... | {
pub name: *const ::libc::c_char,
pub fun: DL_FUNC,
pub numArgs: ::libc::c_int,
pub types: *mut R_NativePrimitiveArgType,
pub styles: *mut R_NativeArgStyle,
}
impl ::std::clone::Clone for R_CMethodDef {
fn clone(&self) -> Self {
*self
}
}
impl ::std::default::Default for R_CMethod... | R_CMethodDef | identifier_name |
component.rs | use std::comm::{TryRecvError,Empty,Disconnected};
use std::fmt;
use message::{Message,MessageData};
use message::MessageData::{MsgStart};
#[deriving(PartialEq,Clone)]
pub enum ComponentType {
ManagerComponent,
ExtractorComponent,
AudioDecoderComponent,
VideoDecoderComponent,
ClockComponent,
Aud... | {
pub component_type: ComponentType,
pub mgr_sender: Option<Sender<Message>>,
pub receiver: Receiver<Message>,
pub sender: Option<Sender<Message>>,
}
impl ComponentStruct {
pub fn new(component_type: ComponentType) -> ComponentStruct {
let (sender, receiver) = channel::<Message>();
... | ComponentStruct | identifier_name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.