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
generic-fn.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 ...
struct Triple {x: int, y: int, z: int} impl Copy for Triple {} pub fn main() { let mut x = 62; let mut y = 63; let a = 'a'; let mut b = 'b'; let p: Triple = Triple {x: 65, y: 66, z: 67}; let mut q: Triple = Triple {x: 68, y: 69, z: 70}; y = id::<int>(x); println!("{}", y); assert...
{ return x; }
identifier_body
extern-call-scrub.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 { count(data - 1u) + count(data - 1u) } } fn count(n: uint) -> uint { unsafe { println!("n = {}", n); rustrt::rust_dbg_call(cb, n) } } pub fn main() { // Make sure we're on a task with small Rust stacks (main currently // has a large stack) task::spawn(proc() { ...
{ data }
conditional_block
extern-call-scrub.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 ...
(data: libc::uintptr_t) -> libc::uintptr_t { if data == 1u { data } else { count(data - 1u) + count(data - 1u) } } fn count(n: uint) -> uint { unsafe { println!("n = {}", n); rustrt::rust_dbg_call(cb, n) } } pub fn main() { // Make sure we're on a task with smal...
cb
identifier_name
extern-call-scrub.rs
// // 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 http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // This time we'...
// 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.
random_line_split
extern-call-scrub.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 ...
{ // Make sure we're on a task with small Rust stacks (main currently // has a large stack) task::spawn(proc() { let result = count(12u); println!("result = {}", result); assert_eq!(result, 2048u); }); }
identifier_body
stack_switcher.rs
// This file was generated by gir (b7f5189) from gir-files (71d73f0) // DO NOT EDIT use Box; use Container; use Orientable; use Stack; use Widget; use ffi; use glib::Value; use glib::object::Downcast; use glib::translate::*; use gobject_ffi; glib_wrapper! { pub struct StackSwitcher(Object<ffi::GtkStackSwitcher>):...
ffi::gtk_stack_switcher_set_stack(self.to_glib_none().0, stack.to_glib_none().0); } } #[cfg(feature = "v3_20")] pub fn get_property_icon_size(&self) -> i32 { let mut value = Value::from(&0); unsafe { gobject_ffi::g_object_get_property(self.to_glib_none().0, "...
} #[cfg(feature = "v3_10")] pub fn set_stack(&self, stack: Option<&Stack>) { unsafe {
random_line_split
stack_switcher.rs
// This file was generated by gir (b7f5189) from gir-files (71d73f0) // DO NOT EDIT use Box; use Container; use Orientable; use Stack; use Widget; use ffi; use glib::Value; use glib::object::Downcast; use glib::translate::*; use gobject_ffi; glib_wrapper! { pub struct StackSwitcher(Object<ffi::GtkStackSwitcher>):...
#[cfg(feature = "v3_10")] pub fn set_stack(&self, stack: Option<&Stack>) { unsafe { ffi::gtk_stack_switcher_set_stack(self.to_glib_none().0, stack.to_glib_none().0); } } #[cfg(feature = "v3_20")] pub fn get_property_icon_size(&self) -> i32 { let mut value = Val...
{ unsafe { from_glib_none(ffi::gtk_stack_switcher_get_stack(self.to_glib_none().0)) } }
identifier_body
stack_switcher.rs
// This file was generated by gir (b7f5189) from gir-files (71d73f0) // DO NOT EDIT use Box; use Container; use Orientable; use Stack; use Widget; use ffi; use glib::Value; use glib::object::Downcast; use glib::translate::*; use gobject_ffi; glib_wrapper! { pub struct StackSwitcher(Object<ffi::GtkStackSwitcher>):...
() -> StackSwitcher { assert_initialized_main_thread!(); unsafe { Widget::from_glib_none(ffi::gtk_stack_switcher_new()).downcast_unchecked() } } #[cfg(feature = "v3_10")] pub fn get_stack(&self) -> Option<Stack> { unsafe { from_glib_none(ffi::gtk_stac...
new
identifier_name
cloudwatch.rs
#![cfg(feature = "cloudwatch")] extern crate rusoto; use rusoto::cloudwatch::{CloudWatchClient, PutMetricDataInput, Dimension, MetricDatum}; use rusoto::{DefaultCredentialsProvider, Region}; #[test] fn
() { let client = CloudWatchClient::new(DefaultCredentialsProvider::new().unwrap(), Region::UsEast1); let metric_data = vec![ MetricDatum { dimensions: Some(vec![Dimension {name: "foo".to_string(), value: "bar".to_string()}]), metric_name: "buffers".to_string(), statistic_values: None...
should_put_metric_data
identifier_name
cloudwatch.rs
use rusoto::cloudwatch::{CloudWatchClient, PutMetricDataInput, Dimension, MetricDatum}; use rusoto::{DefaultCredentialsProvider, Region}; #[test] fn should_put_metric_data() { let client = CloudWatchClient::new(DefaultCredentialsProvider::new().unwrap(), Region::UsEast1); let metric_data = vec![ MetricDatum { ...
#![cfg(feature = "cloudwatch")] extern crate rusoto;
random_line_split
cloudwatch.rs
#![cfg(feature = "cloudwatch")] extern crate rusoto; use rusoto::cloudwatch::{CloudWatchClient, PutMetricDataInput, Dimension, MetricDatum}; use rusoto::{DefaultCredentialsProvider, Region}; #[test] fn should_put_metric_data()
}
{ let client = CloudWatchClient::new(DefaultCredentialsProvider::new().unwrap(), Region::UsEast1); let metric_data = vec![ MetricDatum { dimensions: Some(vec![Dimension {name: "foo".to_string(), value: "bar".to_string()}]), metric_name: "buffers".to_string(), statistic_values: None, ...
identifier_body
issue-14221.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub mod b { pub fn key(e: ::E) -> &'static str { match e { A => "A", //~^ WARN pattern binding `A` is named the same as one of the variants of the type `E` B => "B", //~ ERROR: unreachable pattern //~^ WARN pattern binding `B` is named the same as one of the variants of the type `E` ...
random_line_split
issue-14221.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} fn main() {}
{ match e { A => "A", //~^ WARN pattern binding `A` is named the same as one of the variants of the type `E` B => "B", //~ ERROR: unreachable pattern //~^ WARN pattern binding `B` is named the same as one of the variants of the type `E` } }
identifier_body
issue-14221.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 ...
(e: ::E) -> &'static str { match e { A => "A", //~^ WARN pattern binding `A` is named the same as one of the variants of the type `E` B => "B", //~ ERROR: unreachable pattern //~^ WARN pattern binding `B` is named the same as one of the variants of the type `E` } } } fn main...
key
identifier_name
type_of.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 ...
pub fn type_of_explicit_arg(ccx: @CrateContext, arg: &ty::arg) -> TypeRef { let llty = type_of(ccx, arg.ty); if arg_is_indirect(ccx, arg) {T_ptr(llty)} else {llty} } pub fn type_of_explicit_args(ccx: @CrateContext, inputs: &[ty::arg]) -> ~[TypeRef] { inputs.map(|arg| type_of_...
{ match ty::resolved_mode(ccx.tcx, arg.mode) { ast::by_copy => !ty::type_is_immediate(arg.ty), ast::by_ref => true } }
identifier_body
type_of.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 ...
(cx: @CrateContext, t: ty::t) -> TypeRef { debug!("type_of %?: %?", t, ty::get(t)); // Check the cache. match cx.lltypes.find(&t) { // FIXME(#5562): removing this copy causes a segfault in stage1 core Some(t) => return /*bad*/ copy *t, None => () } // Replace any typedef'd ...
type_of
identifier_name
type_of.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 ...
}; cx.llsizingtypes.insert(t, llsizingty); llsizingty } // NB: If you update this, be sure to update `sizing_type_of()` as well. pub fn type_of(cx: @CrateContext, t: ty::t) -> TypeRef { debug!("type_of %?: %?", t, ty::get(t)); // Check the cache. match cx.lltypes.find(&t) { // FIXME(#...
}
random_line_split
markdown.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>(&'self str); static OUTPUT_UNIT: libc::size_t = 64; static MKDEXT_NO_INTRA_EMPHASIS: libc::c_uint = 1 << 0; static MKDEXT_TABLES: libc::c_uint = 1 << 1; static MKDEXT_FENCED_CODE: libc::c_uint = 1 << 2; static MKDEXT_AUTOLINK: libc::c_uint = 1 << 3; static MKDEXT_STRIKETHROUGH: libc::c_uint = 1 << 4; static MK...
Markdown
identifier_name
markdown.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 ...
render(fmt.buf, md.as_slice()); } }
{ return; }
conditional_block
markdown.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 ...
}
{ // This is actually common enough to special-case if md.len() == 0 { return; } render(fmt.buf, md.as_slice()); }
identifier_body
markdown.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 ...
callbacks: *sd_callbacks, opaque: *libc::c_void) -> *sd_markdown; fn sd_markdown_render(ob: *buf, document: *u8, doc_size: libc::size_t, md: *sd_markdown); fn sd_markdown_free(md: *sd_mark...
fn sdhtml_renderer(callbacks: *sd_callbacks, options_ptr: *html_renderopt, render_flags: libc::c_uint); fn sd_markdown_new(extensions: libc::c_uint, max_nesting: libc::size_t,
random_line_split
services.rs
//! This module defines the metadata on devices and services. //! //! Note that all the data structures in this module represent //! snapshots of subsets of the devices available. None of these data //! structures are live, so there is always the possibility that //! devices may have been added or removed from the `Fox...
(&self) -> JSON { vec![ ("id", self.id.to_json()), ("adapter", self.adapter.to_json()), ("tags", self.tags.to_json()), ("properties", self.properties.to_json()), ("channels", self.channels.to_json()), ] .to_json() } }
to_json
identifier_name
services.rs
//! This module defines the metadata on devices and services. //! //! Note that all the data structures in this module represent //! snapshots of subsets of the devices available. None of these data //! structures are live, so there is always the possibility that
//! these data structures are read. use channel::*; use parse::*; pub use util::{Exactly, Maybe, Id, AdapterId, ServiceId, KindId, TagId, VendorId}; use std::collections::{HashSet, HashMap}; // A helper macro to create a Id<ServiceId> without boilerplate. #[macro_export] macro_rules! service_id { ($val:expr) => ...
//! devices may have been added or removed from the `FoxBox` by the time
random_line_split
cqe.rs
// Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 use crate::bindings::io_uring_cqe; use std::result::Result; use vm_memory::ByteValued; unsafe impl ByteValued for io_uring_cqe {} /// Wrapper over a completed operation. pub struct Cqe<T> { res: i32,...
() { let user_data = Box::new(10u8); let cqe: Cqe<u8> = unsafe { Cqe::new(io_uring_cqe { user_data: Box::into_raw(user_data) as u64, res: 0, flags: 0, }) }; assert_eq!(cqe.user_data(), 10); } }
test_user_data
identifier_name
cqe.rs
// Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 use crate::bindings::io_uring_cqe; use std::result::Result; use vm_memory::ByteValued; unsafe impl ByteValued for io_uring_cqe {} /// Wrapper over a completed operation. pub struct Cqe<T> { res: i32,...
/// Consume the object and return the user_data. pub fn user_data(self) -> T { *self.user_data } } #[cfg(test)] mod tests { use super::*; #[test] fn test_result() { // Check that `result()` returns an `Error` when `res` is negative. { let user_data = Box::n...
{ Cqe { res: self.res, user_data: Box::new(op(self.user_data())), } }
identifier_body
cqe.rs
// Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 use crate::bindings::io_uring_cqe; use std::result::Result; use vm_memory::ByteValued; unsafe impl ByteValued for io_uring_cqe {} /// Wrapper over a completed operation. pub struct Cqe<T> { res: i32,...
let user_data = Box::new(10u8); let cqe: Cqe<u8> = unsafe { Cqe::new(io_uring_cqe { user_data: Box::into_raw(user_data) as u64, res: -22, flags: 0, }) }; assert_eq!( ...
#[test] fn test_result() { // Check that `result()` returns an `Error` when `res` is negative. {
random_line_split
cqe.rs
// Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 use crate::bindings::io_uring_cqe; use std::result::Result; use vm_memory::ByteValued; unsafe impl ByteValued for io_uring_cqe {} /// Wrapper over a completed operation. pub struct Cqe<T> { res: i32,...
else { Ok(res as u32) } } /// Create a new Cqe, applying the passed function to the user_data. pub fn map_user_data<U, F: FnOnce(T) -> U>(self, op: F) -> Cqe<U> { Cqe { res: self.res, user_data: Box::new(op(self.user_data())), } } /// Co...
{ Err(std::io::Error::from_raw_os_error(res)) }
conditional_block
issue-1701.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 ...
assert_eq!(noise(animal::dog(breed::pug)), Some("woof".to_string())); assert_eq!(noise(animal::rabbit("Hilbert".to_string(), ear_kind::upright)), None); assert_eq!(noise(animal::tiger), Some("roar".to_string())); }
pub fn main() { assert_eq!(noise(animal::cat(pattern::tabby)), Some("meow".to_string()));
random_line_split
issue-1701.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 ...
animal::rabbit(..) => { None } animal::tiger(..) => { Some("roar".to_string()) } } } pub fn main() { assert_eq!(noise(animal::cat(pattern::tabby)), Some("meow".to_string())); assert_eq!(noise(animal::dog(breed::pug)), Some("woof".to_string())); assert_eq!(noise(animal::rabbit("Hilbert".to...
{ Some("woof".to_string()) }
conditional_block
issue-1701.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 ...
{ cat(pattern), dog(breed), rabbit(name, ear_kind), tiger } fn noise(a: animal) -> Option<String> { match a { animal::cat(..) => { Some("meow".to_string()) } animal::dog(..) => { Some("woof".to_string()) } animal::rabbit(..) => { None } animal::tiger(..) => { Some("roar".to_string()...
animal
identifier_name
issue-1701.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 ...
pub fn main() { assert_eq!(noise(animal::cat(pattern::tabby)), Some("meow".to_string())); assert_eq!(noise(animal::dog(breed::pug)), Some("woof".to_string())); assert_eq!(noise(animal::rabbit("Hilbert".to_string(), ear_kind::upright)), None); assert_eq!(noise(animal::tiger), Some("roar".to_string()));...
{ match a { animal::cat(..) => { Some("meow".to_string()) } animal::dog(..) => { Some("woof".to_string()) } animal::rabbit(..) => { None } animal::tiger(..) => { Some("roar".to_string()) } } }
identifier_body
one.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 ...
#[test] fn stampede_once() { static mut o: Once = ONCE_INIT; static mut run: bool = false; let (tx, rx) = channel(); for _ in range(0u, 10) { let tx = tx.clone(); spawn(proc() { for _ in range(0u, 4) { task::deschedule() } ...
{ static mut o: Once = ONCE_INIT; let mut a = 0i; unsafe { o.doit(|| a += 1); } assert_eq!(a, 1); unsafe { o.doit(|| a += 1); } assert_eq!(a, 1); }
identifier_body
one.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 ...
{ mutex: StaticMutex, cnt: atomics::AtomicInt, lock_cnt: atomics::AtomicInt, } /// Initialization value for static `Once` values. pub static ONCE_INIT: Once = Once { mutex: MUTEX_INIT, cnt: atomics::INIT_ATOMIC_INT, lock_cnt: atomics::INIT_ATOMIC_INT, }; impl Once { /// Perform an initial...
Once
identifier_name
one.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 ...
assert!(!run); run = true; }); assert!(run); } for _ in range(0u, 10) { rx.recv(); } } }
o.doit(|| {
random_line_split
one.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 ...
drop(guard); // Last one out cleans up after everyone else, no leaks! if self.lock_cnt.fetch_add(-1, atomics::SeqCst) == 1 { unsafe { self.mutex.destroy() } } } } #[cfg(test)] mod test { use std::prelude::*; use std::task; use super::{ONCE_INIT, Once}; ...
{ f(); let prev = self.cnt.swap(int::MIN, atomics::SeqCst); self.lock_cnt.store(prev, atomics::SeqCst); }
conditional_block
lib.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...
b.iter(|| { arena.alloc(|| Noncopy { string: "hello world".to_string(), array: vec!( 1, 2, 3, 4, 5 ), }) }) } }
random_line_split
lib.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...
#[bench] pub fn bench_noncopy(b: &mut Bencher) { let arena = TypedArena::new(); b.iter(|| { arena.alloc(Noncopy { string: "hello world".to_string(), array: vec!( 1, 2, 3, 4, 5 ), }) }) } #[bench] pub fn bench_noncopy_...
{ let arena = TypedArena::new(); for _ in range(0, 100000) { arena.alloc(Noncopy { string: "hello world".to_string(), array: vec!( 1, 2, 3, 4, 5 ), }); } }
identifier_body
lib.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...
Some(mut next) => { // We assume that the next chunk is completely filled. next.destroy(next.capacity) } } } // Returns a pointer to the first allocated object. #[inline] fn start(&self) -> *u8 { let this: *TypedArenaChunk<T> = se...
{}
conditional_block
lib.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...
{ data: Rc<RefCell<Vec<u8> >>, fill: Cell<uint>, is_copy: Cell<bool>, } impl Chunk { fn capacity(&self) -> uint { self.data.borrow().capacity() } unsafe fn as_ptr(&self) -> *u8 { self.data.borrow().as_ptr() } } /// A slower reflection-based arena that can allocate objects ...
Chunk
identifier_name
rover-server.rs
extern crate rpizw_rover; extern crate iron; extern crate router; extern crate mount; extern crate staticfile; extern crate unicase; extern crate logger; #[macro_use] extern crate chan; extern crate chan_signal; #[macro_use] extern crate log; extern crate env_logger; #[macro_use] extern crate serde_derive; extern crate...
(_: &mut Request) -> IronResult<Response> { rtry!(reset_rover()); Ok(ResponsePayload::success().to_response()) } /// Stops the rover from moving. Equlivent to settings its speed to 0. fn stop(_: &mut Request) -> IronResult<Response> { let rover = rtry!(Rover::new(PWM_CHIP, LEFT_PWM, RIGHT_PWM)); rtry!(...
reset
identifier_name
rover-server.rs
extern crate rpizw_rover; extern crate iron; extern crate router; extern crate mount; extern crate staticfile; extern crate unicase; extern crate logger; #[macro_use] extern crate chan; extern crate chan_signal; #[macro_use] extern crate log; extern crate env_logger; #[macro_use] extern crate serde_derive; extern crate...
/// The reponse that is sent when an error in encountered. pub fn error(error: String) -> ResponsePayload { ResponsePayload::Error { success: false, error: error, } } /// The response that is sent when a reqeust is carried out without error /// and there is no...
Simple { success: bool }, } impl ResponsePayload {
random_line_split
rover-server.rs
extern crate rpizw_rover; extern crate iron; extern crate router; extern crate mount; extern crate staticfile; extern crate unicase; extern crate logger; #[macro_use] extern crate chan; extern crate chan_signal; #[macro_use] extern crate log; extern crate env_logger; #[macro_use] extern crate serde_derive; extern crate...
CORS::add_headers(&mut res); Ok(res) } fn catch(&self, _: &mut Request, mut err: IronError) -> IronResult<Response> { CORS::add_headers(&mut err.response); Err(err) } }
{ res = Response::with(status::Ok); }
conditional_block
rover-server.rs
extern crate rpizw_rover; extern crate iron; extern crate router; extern crate mount; extern crate staticfile; extern crate unicase; extern crate logger; #[macro_use] extern crate chan; extern crate chan_signal; #[macro_use] extern crate log; extern crate env_logger; #[macro_use] extern crate serde_derive; extern crate...
/// Helper function to ensure the rover is stopped, enabled and ready to start. fn reset_rover() -> rpizw_rover::error::Result<()> { let rover = Rover::new(PWM_CHIP, LEFT_PWM, RIGHT_PWM)?; rover.export()?; rover.enable(false)?; rover.unexport()?; rover.export()?; rover.stop()?; rover.enabl...
{ #[derive(Serialize, Deserialize, Debug)] struct SpeedRequest { left: i8, right: i8, } let mut body = String::new(); rtry!(req.body.read_to_string(&mut body)); let SpeedRequest { left, right } = rtry!(serde_json::from_str(&body), "inv...
identifier_body
error.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...
} impl From<DecoderError> for Error { fn from(err: DecoderError) -> Self { Error::Decoder(err) } } impl<E> From<Box<E>> for Error where Error: From<E> { fn from(err: Box<E>) -> Self { Error::from(*err) } }
{ Error::Trie(err) }
identifier_body
error.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...
(err: TrieError) -> Self { Error::Trie(err) } } impl From<DecoderError> for Error { fn from(err: DecoderError) -> Self { Error::Decoder(err) } } impl<E> From<Box<E>> for Error where Error: From<E> { fn from(err: Box<E>) -> Self { Error::from(*err) } }
from
identifier_name
error.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...
Error::UnrecognizedCodeState(state) => write!(f, "Unrecognized code encoding ({})", state), Error::RestorationAborted => write!(f, "Snapshot restoration aborted."), Error::Io(ref err) => err.fmt(f), Error::Decoder(ref err) => err.fmt(f), Error::Trie(ref err) => err.fmt(f), Error::VersionNotSupported(r...
write!(f, "Block {} had wrong hash. expected {:?}, got {:?}", num, expected, found), Error::TooManyBlocks(ref expected, ref found) => write!(f, "Snapshot contained too many blocks. Expected {}, got {}", expected, found), Error::OldBlockPrunedDB => write!(f, "Attempted to create a snapshot at an old block whil...
random_line_split
ThresholdDifferenceComparer.rs
#pragma version(1) #pragma rs java_package_name(com.android.cts.uirendering) int WIDTH; int THRESHOLD; rs_allocation ideal; rs_allocation given; // This method does a threshold comparison of the values void thresholdCompare(const int32_t *v_in, float *v_out){ int y = v_in[0]; v_out[0] = 0; for(int i = 0...
} }
random_line_split
lib.rs
#![warn(missing_docs, trivial_numeric_casts, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results)]
//! //! This is a very niche string type - generally, you are better off using `std::string::String`, or the //! `AsciiString` type from the `ascii` crate if you need an ascii string. They have no upper size limit, and //! are cheaper to pass around as they are only 64 bytes on the stack. Generally, you should only use...
//! # Pascal strings in Rust. //! //! A `PascalString`, or `ShortString` is a String which stores its data on the stack. Because of this, it has //! a fixed maximum size, which cannot be changed. Traditionally, the size of a `PascalString` is 256 bytes - //! the first byte stores the length, which means that each remai...
random_line_split
window.rs
#![allow(non_snake_case)] #![allow(unused_variables)] use libc::{c_int,c_void}; use std::rc::Rc; use std::cell::RefCell; use super::super::win::wnd::{TWnd,DWnd}; use super::super::event::eventlistener::{TEventProcesser,EventProcesser}; use super::super::win::types::*; use super::super::win::api::*; use super::super...
Window{ // fn getSelf(&mut self)->&mut Window{self} fn preTranslateMsg(&self,msg:&mut MSG)->bool { msg.TranslateMessage(); msg.DispatchMessage(); false } fn setWndProc(&mut self,wproc:WndProc){self.defWindowProc=wproc;} fn getWndProc(&self)->WndProc{self.defWindowProc} fn msgProcedure(&self, ...
er for
identifier_name
window.rs
#![allow(non_snake_case)] #![allow(unused_variables)] use libc::{c_int,c_void}; use std::rc::Rc; use std::cell::RefCell; use super::super::win::wnd::{TWnd,DWnd}; use super::super::event::eventlistener::{TEventProcesser,EventProcesser}; use super::super::win::types::*;
//use super::super::widgets::button::Button; //use super::super::widgets::edit::Edit; use super::super::{Dust,TLS_DUST,hookWndCreate,UnHookWndCreate,emptyWndProc,MessageBox}; //use super::super::widgets::button::Button; // 所有窗口 组件 都必须实现的接口。 // 部分方法 preTranslate wndProc 消息映射需要用到. pub struct Window{ defWindowProc: W...
use super::super::win::api::*; use super::super::win::encode::*; use super::super::event::*;
random_line_split
window.rs
#![allow(non_snake_case)] #![allow(unused_variables)] use libc::{c_int,c_void}; use std::rc::Rc; use std::cell::RefCell; use super::super::win::wnd::{TWnd,DWnd}; use super::super::event::eventlistener::{TEventProcesser,EventProcesser}; use super::super::win::types::*; use super::super::win::api::*; use super::super...
fn msgProcedure(&self, hWin: DWnd, msg:u32, wparam:WPARAM, lparam:LPARAM)->int { // println!("DWnd={}, msg={}, wparam={}, lparam={}", hWnd, msg, wparam, lparam); match msg{ 1=>{ //创建完毕 println!("Window On Created! {} {}", hWin.GetText(),0i); // Button::new(self, "点点点",10,10,200,25,100);...
dProc{self.defWindowProc}
identifier_body
window.rs
#![allow(non_snake_case)] #![allow(unused_variables)] use libc::{c_int,c_void}; use std::rc::Rc; use std::cell::RefCell; use super::super::win::wnd::{TWnd,DWnd}; use super::super::event::eventlistener::{TEventProcesser,EventProcesser}; use super::super::win::types::*; use super::super::win::api::*; use super::super...
hWin, msg, wparam, lparam) as int; } } } impl Drop for Window{ fn drop(&mut self){ println!("drop window"); } } extern "stdcall" fn defWindowProc(hWnd:DWnd, msg: u32, wparam: WPARAM,lparam: LPARAM)->c_int{ unsafe{ DefWindowProcW(hWnd,msg,wparam,lparam) } } impl Window{ pub fn new(title:&str, ...
ndowProc,
conditional_block
regions-glb-free-free.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, s: &str) -> Flag<'a> { Flag { //~ ERROR cannot infer name: self.name, desc: s, max_count: self.max_count, value: self.value } } } } fn main () { let f : argparse::Flag = argparse::flag("flag".to_owned(), "My ...
set_desc
identifier_name
regions-glb-free-free.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. mod argparse { pub struct Flag<'a> { name: &'a str, desc: &'a str, max_count: uint, value: uint } pub fn flag...
// 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
random_line_split
capture.rs
extern crate rscam; extern crate image; use self::rscam::{Camera, Config}; use self::image::{ ImageBuffer, Rgba, Rgb, Luma, ConvertBuffer, GenericImage }; use std::sync::mpsc::Sender; use std::thread; use std::time; use std::path::Path; pub fn stream(sender : Sender<ImageBuffer<Rgba<u8>, Vec<...
(device : String) -> ImageBuffer<Rgba<u8>, Vec<u8>> { let mut cam = Camera::new(device.as_str()).unwrap(); cam.start(&Config { interval: (1, 30), resolution: (640, 480), format: b"RGB3", ..Default::default() }).unwrap(); let frame = cam.capture().unwrap(); let frame ...
capture
identifier_name
capture.rs
extern crate rscam; extern crate image; use self::rscam::{Camera, Config}; use self::image::{ ImageBuffer, Rgba, Rgb, Luma, ConvertBuffer, GenericImage }; use std::sync::mpsc::Sender; use std::thread; use std::time; use std::path::Path; pub fn stream(sender : Sender<ImageBuffer<Rgba<u8>, Vec<...
pub fn fake_capture(image : &str) -> ImageBuffer<Luma<u8>, Vec<u8>> { let frame = image::open(&Path::new(image)).unwrap(); ImageBuffer::from_fn(frame.width(), frame.height(), |x, y| frame.get_pixel(x, y)).convert() }
{ let mut cam = Camera::new(device.as_str()).unwrap(); cam.start(&Config { interval: (1, 30), resolution: (640, 480), format: b"RGB3", ..Default::default() }).unwrap(); let frame = cam.capture().unwrap(); let frame : ImageBuffer<Rgb<u8>, _> = ImageBuffer::fr...
identifier_body
capture.rs
extern crate rscam; extern crate image; use self::rscam::{Camera, Config}; use self::image::{ ImageBuffer, Rgba, Rgb, Luma, ConvertBuffer, GenericImage }; use std::sync::mpsc::Sender; use std::thread; use std::time; use std::path::Path; pub fn stream(sender : Sender<ImageBuffer<Rgba<u8>, Vec<...
} }); } pub fn fake_stream(sender : Sender<ImageBuffer<Rgba<u8>, Vec<u8>>>, image : String) { thread::spawn(move || { let frame = image::open(&Path::new(image.as_str())).unwrap(); let frame : ImageBuffer<Rgb<u8>, Vec<u8>> = ImageBuffer::from_fn(frame.width(), frame.height(...
{ break; }
conditional_block
capture.rs
extern crate rscam; extern crate image; use self::rscam::{Camera, Config}; use self::image::{ ImageBuffer, Rgba, Rgb, Luma, ConvertBuffer, GenericImage }; use std::sync::mpsc::Sender; use std::thread; use std::time; use std::path::Path; pub fn stream(sender : Sender<ImageBuffer<Rgba<u8>, Vec<...
let frame = cam.capture().unwrap(); let frame : ImageBuffer<Rgb<u8>, _> = ImageBuffer::from_raw(frame.resolution.0, frame.resolution.1, frame).unwrap(); return frame.convert(); } pub fn fake_capture(image : &str) -> ImageBuffer<Luma<u8...
random_line_split
lib.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. use futures::{future::BoxFuture, Future, FutureExt, TryFutureExt}; use std::{ error, fmt, io, pin::Pin, process::{ExitStatus, Output}, }; pub use tokio::pr...
match *self { CmdError::Io(ref err) => write!(f, "{}", err), CmdError::Output(ref err) => write!( f, "{}, stdout: {}, stderr: {}", err.status, String::from_utf8_lossy(&err.stdout), String::from_utf8_lossy(&er...
impl reject::Reject for CmdError {} impl fmt::Display for CmdError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
random_line_split
lib.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. use futures::{future::BoxFuture, Future, FutureExt, TryFutureExt}; use std::{ error, fmt, io, pin::Pin, process::{ExitStatus, Output}, }; pub use tokio::pr...
}
{ tracing::debug!("Child waiting for output: {:?}", self); self.wait_with_output() .err_into() .and_then(|x| async { if x.status.success() { Ok(x) } else { Err(x.into()) } }) ...
identifier_body
lib.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. use futures::{future::BoxFuture, Future, FutureExt, TryFutureExt}; use std::{ error, fmt, io, pin::Pin, process::{ExitStatus, Output}, }; pub use tokio::pr...
(&mut self) -> BoxFuture<Result<Output, CmdError>> { tracing::debug!("Running cmd: {:?}", self); self.output() .err_into() .and_then(|x| async { if x.status.success() { Ok(x) } else { Err(x.into()) ...
checked_output
identifier_name
builder.rs
create the backing buffer // directly, bypassing the typical way of using grow_owned_buf: assert!( size <= FLATBUFFERS_MAX_BUFFER_SIZE, "cannot initialize buffer bigger than 2 gigabytes" );
field_locs: Vec::new(), written_vtable_revpos: Vec::new(), nested: false, finished: false, min_align: 0, _phantom: PhantomData, } } /// Reset the FlatBufferBuilder internal state. Use this method after a /// call to a `finis...
FlatBufferBuilder { owned_buf: vec![0u8; size], head: size,
random_line_split
builder.rs
fn push_slot<X: Push + PartialEq>(&mut self, slotoff: VOffsetT, x: X, default: X) { self.assert_nested("push_slot"); if x == default { return; } self.push_slot_always(slotoff, x); } /// Push a Push'able value onto the front of the in-progress data, and /// store...
{ // we don't assert that self.field_locs.len() >0 because the vtable // could be empty (e.g. for empty tables, or for all-default values). debug_assert!( self.nested, format!( "incorrect FlatBufferBuilder usage: {} must be called while in a nested state",...
identifier_body
builder.rs
the backing buffer // directly, bypassing the typical way of using grow_owned_buf: assert!( size <= FLATBUFFERS_MAX_BUFFER_SIZE, "cannot initialize buffer bigger than 2 gigabytes" ); FlatBufferBuilder { owned_buf: vec![0u8; size], head: s...
<'a: 'b, 'b>(&'a mut self, s: &'b str) -> WIPOffset<&'fbb str> { self.assert_not_nested( "create_string can not be called when a table or vector is under construction", ); WIPOffset::new(self.create_byte_string(s.as_bytes()).value()) } /// Create a zero-terminated byte vecto...
create_string
identifier_name
builder.rs
the backing buffer // directly, bypassing the typical way of using grow_owned_buf: assert!( size <= FLATBUFFERS_MAX_BUFFER_SIZE, "cannot initialize buffer bigger than 2 gigabytes" ); FlatBufferBuilder { owned_buf: vec![0u8; size], head: s...
}; { let n = self.head + self.used_space() - object_revloc_to_vtable.value() as usize; let saw = read_scalar_at::<UOffsetT>(&self.owned_buf, n); debug_assert_eq!(saw, 0xF0F0_F0F0); emplace_scalar::<SOffsetT>( &mut self.owned_buf[n..n + SI...
{ let new_vt_use = self.used_space() as UOffsetT; self.written_vtable_revpos.push(new_vt_use); new_vt_use }
conditional_block
object.rs
use libc::c_void; use llvm_sys::object::{self, LLVMObjectFileRef, LLVMSymbolIteratorRef}; use cbox::CBox; use std::fmt; use std::iter::Iterator; use std::marker::PhantomData; use std::mem; use super::buffer::MemoryBuffer; use super::util; /// An external object file that has been parsed by LLVM. pub struct ObjectFile ...
} impl<'a> Symbol<'a> { /// Get the pointer for this symbol. pub unsafe fn get<T>(self) -> &'a T { mem::transmute(self.address) } }
{ write!(fmt, "{} - {}", self.name, self.size) }
identifier_body
object.rs
use libc::c_void; use llvm_sys::object::{self, LLVMObjectFileRef, LLVMSymbolIteratorRef}; use cbox::CBox; use std::fmt; use std::iter::Iterator; use std::marker::PhantomData; use std::mem; use super::buffer::MemoryBuffer; use super::util; /// An external object file that has been parsed by LLVM. pub struct ObjectFile ...
/// Parse the object file at the path given, or return an error string if an error occurs. pub fn read(path: &str) -> Result<ObjectFile, CBox<str>> { let buf = try!(MemoryBuffer::new_from_file(path)); unsafe { let ptr = object::LLVMCreateObjectFile(buf.as_ptr()); if ptr.i...
} native_ref!(ObjectFile, obj: LLVMObjectFileRef); impl ObjectFile {
random_line_split
object.rs
use libc::c_void; use llvm_sys::object::{self, LLVMObjectFileRef, LLVMSymbolIteratorRef}; use cbox::CBox; use std::fmt; use std::iter::Iterator; use std::marker::PhantomData; use std::mem; use super::buffer::MemoryBuffer; use super::util; /// An external object file that has been parsed by LLVM. pub struct ObjectFile ...
(path: &str) -> Result<ObjectFile, CBox<str>> { let buf = try!(MemoryBuffer::new_from_file(path)); unsafe { let ptr = object::LLVMCreateObjectFile(buf.as_ptr()); if ptr.is_null() { Err(CBox::from("unknown error")) } else { Ok(ptr.into()...
read
identifier_name
object.rs
use libc::c_void; use llvm_sys::object::{self, LLVMObjectFileRef, LLVMSymbolIteratorRef}; use cbox::CBox; use std::fmt; use std::iter::Iterator; use std::marker::PhantomData; use std::mem; use super::buffer::MemoryBuffer; use super::util; /// An external object file that has been parsed by LLVM. pub struct ObjectFile ...
else { Ok(ptr.into()) } } } /// Iterate through the symbols in this object file. pub fn symbols(&self) -> Symbols { Symbols { iter: unsafe { object::LLVMGetSymbols(self.obj) }, marker: PhantomData, } } } pub struct Symbols<'a> ...
{ Err(CBox::from("unknown error")) }
conditional_block
failure.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
//! //! fn begin_unwind(fmt: &fmt::Arguments, file: &str, line: uint) ->!; //! //! This definition allows for failing with any general message, but it does not //! allow for failing with a `~Any` value. The reason for this is that libcore //! is not allowed to allocate. //! //! This module contains a few other fail...
//! The core library cannot define failure, but it does *declare* failure. This //! means that the functions inside of libcore are allowed to fail, but to be //! useful an upstream crate must define failure for libcore to use. The current //! interface for failure is:
random_line_split
failure.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 ...
(expr: *u8, file: *u8, line: uint) ->! { unsafe { let expr = c_str_to_static_slice(expr as *i8); let file = c_str_to_static_slice(file as *i8); format_args!(|args| -> () { begin_unwind(args, file, line); }, "{}", expr); loop {} } } #[cold] #[lang="fail_bound...
fail_
identifier_name
failure.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 ...
#[cold] pub fn begin_unwind(fmt: &fmt::Arguments, file: &'static str, line: uint) ->! { // FIXME: this should be a proper lang item, it should not just be some // undefined symbol sitting in the middle of nowhere. #[allow(ctypes)] extern { fn rust_begin_unwind(fmt: &fmt::Arguments, file: &'stat...
{ let file = unsafe { c_str_to_static_slice(file as *i8) }; format_args!(|args| -> () { begin_unwind(args, file, line); }, "index out of bounds: the len is {} but the index is {}", len, index); loop {} }
identifier_body
rustplugin.rs
// compile with // rustc --crate-type dylib rustplugin.rs // on windows: // rustc --crate-type cdylib -C opt-level=3 -C link-args=-s -C prefer-dynamic rustplugin.rs use std::os::raw::{c_void,c_char,c_uchar,c_int,c_uint,c_double,c_float}; use std::ffi::CString; const VOO_PLUGIN_API_VERSION: i32 = 6; // display pi...
// call this again as long as you return TRUE. (only called when b_fileBased is true) file_suffixes: unsafe extern fn( idx: c_int, pp_suffix: *const *mut c_char, p_user_seq: *const c_void ) -> c_int, // Called by vooya to enumerate meta information tags about the video you provide. // idx is counting up for each c...
error_msg: unsafe extern fn( pp_err: *const *mut c_char, p_user_seq: *const c_void ) -> (), // Called by vooya to get supported file extensions. Those are then displayed in // the "Open file" dialog. vooya will start with idx=0, then increment idx and
random_line_split
rustplugin.rs
// compile with // rustc --crate-type dylib rustplugin.rs // on windows: // rustc --crate-type cdylib -C opt-level=3 -C link-args=-s -C prefer-dynamic rustplugin.rs use std::os::raw::{c_void,c_char,c_uchar,c_int,c_uint,c_double,c_float}; use std::ffi::CString; const VOO_PLUGIN_API_VERSION: i32 = 6; // display p...
{ vooDataArrangement_Unknown = -1, vooDA_planar_420, vooDA_planar_422, vooDA_planar_444, vooDA_planar_410, vooDA_planar_411, vooDA_uyvy, vooDA_yuyv, vooDA_yuy2, vooDA_nv12, vooDA_v210, vooDA_interleaved_410, vooDA_interleaved_411, vooDA_reserved0, vooDA_interleaved_422, vooDA_interleaved_444, vooDA_si...
voo_dataArrangement_t
identifier_name
rustplugin.rs
// compile with // rustc --crate-type dylib rustplugin.rs // on windows: // rustc --crate-type cdylib -C opt-level=3 -C link-args=-s -C prefer-dynamic rustplugin.rs use std::os::raw::{c_void,c_char,c_uchar,c_int,c_uint,c_double,c_float}; use std::ffi::CString; const VOO_PLUGIN_API_VERSION: i32 = 6; // display p...
for y in 0..p_seq_info.height { for x in 0..p_seq_info.width { let ref mut p: voo_target_space_t = *p_data.offset( (x + p_seq_info.width * y) as isize ); let luma : i32 = (130 * p.r as i32 + 256 * p.g as i32 + 50 * p.b as i32) >> 8; p.r = std::cmp::min( 255, luma ) as u8; p.g = std::cmp::min( 255, lu...
{ return; }
conditional_block
structure-constructor-type-mismatch.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 ...
type PairF<U> = Pair<f32,U>; fn main() { let pt = PointF { //~^ ERROR structure constructor specifies a structure of type //~| expected f32 //~| found integral variable x: 1, y: 2, }; let pt2 = Point::<f32> { //~^ ERROR structure constructor specifies a str...
struct Pair<T,U> { x: T, y: U, }
random_line_split
structure-constructor-type-mismatch.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<T> { x: T, y: T, } type PointF = Point<f32>; struct Pair<T,U> { x: T, y: U, } type PairF<U> = Pair<f32,U>; fn main() { let pt = PointF { //~^ ERROR structure constructor specifies a structure of type //~| expected f32 //~| found integral variable x: 1, y:...
Point
identifier_name
mod.rs
use std::{cell::RefCell, collections::HashMap, convert::TryFrom, os::unix::net::UnixStream, rc::Rc}; use smithay::{ reexports::wayland_server::{protocol::wl_surface::WlSurface, Client}, utils::{Logical, Point}, wayland::compositor::give_role, }; use x11rb::{ connection::Connection as _, errors::Re...
(&mut self, window: Window, surface: WlSurface, location: Point<i32, Logical>) { debug!(self.log, "Matched X11 surface {:x?} to {:x?}", window, surface); if give_role(&surface, "x11_surface").is_err() { // It makes no sense to post a protocol error here since that would only kill Xwayland ...
new_window
identifier_name
mod.rs
use std::{cell::RefCell, collections::HashMap, convert::TryFrom, os::unix::net::UnixStream, rc::Rc}; use smithay::{ reexports::wayland_server::{protocol::wl_surface::WlSurface, Client}, utils::{Logical, Point}, wayland::compositor::give_role, }; use x11rb::{ connection::Connection as _, errors::Re...
aux = aux.border_width(u32::try_from(r.border_width).unwrap()); } self.conn.configure_window(r.window, &aux)?; } Event::MapRequest(r) => { // Just grant the wish self.conn.map_window(r.window)?; } ...
random_line_split
mod.rs
use std::{cell::RefCell, collections::HashMap, convert::TryFrom, os::unix::net::UnixStream, rc::Rc}; use smithay::{ reexports::wayland_server::{protocol::wl_surface::WlSurface, Client}, utils::{Logical, Point}, wayland::compositor::give_role, }; use x11rb::{ connection::Connection as _, errors::Re...
} // Called when a WlSurface commits. pub fn commit_hook(surface: &WlSurface) { // Is this the Xwayland client? if let Some(client) = surface.as_ref().client() { if let Some(x11) = client.data_map().get::<Rc<RefCell<X11State>>>() { let mut inner = x11.borrow_mut(); // Is the su...
{ debug!(self.log, "Matched X11 surface {:x?} to {:x?}", window, surface); if give_role(&surface, "x11_surface").is_err() { // It makes no sense to post a protocol error here since that would only kill Xwayland error!(self.log, "Surface {:x?} already has a role?!", surface); ...
identifier_body
insertion_sort.rs
#![doc="Insertion sort algorithms
/// Performs insertion sort on a slice of type T pub fn insertion_sort_slice<T : PartialOrd>(data : &mut [T]){ let n = data.len(); for j in (1..n){ // we insert data[j] into the sorted sequence //data[0...j-1] let mut i = j -1; while data[i] > data[i+1]{ data.swap(i...
"] // std imports use std::ptr;
random_line_split
insertion_sort.rs
#![doc="Insertion sort algorithms "] // std imports use std::ptr; /// Performs insertion sort on a slice of type T pub fn insertion_sort_slice<T : PartialOrd>(data : &mut [T]){ let n = data.len(); for j in (1..n){ // we insert data[j] into the sorted sequence //data[0...j-1] let mut ...
(b: &mut Bencher){ // create a task-local Random Number Generator let mut rng = rand::thread_rng(); let mut v: Vec<usize> = rng.gen_iter::<usize>().take(10000).collect(); b.iter(|| { insertion_sort_slice(v.as_mut_slice()); }); } #[bench] fn bench_insertio...
bench_insertion_sort_slice_random_data
identifier_name
insertion_sort.rs
#![doc="Insertion sort algorithms "] // std imports use std::ptr; /// Performs insertion sort on a slice of type T pub fn insertion_sort_slice<T : PartialOrd>(data : &mut [T])
/// Performs insertion sort on a buffer of data pub unsafe fn insertion_sort_buffer<T : PartialOrd>(data : *mut T, n : usize){ for j in (1..n){ // we insert data[j] into the sorted sequence //data[0...j-1] let mut i = (j -1) as isize; let mut di = data.offset(i); let mut d...
{ let n = data.len(); for j in (1..n){ // we insert data[j] into the sorted sequence //data[0...j-1] let mut i = j -1; while data[i] > data[i+1]{ data.swap(i + 1, i); if i == 0{ break; } i -= 1; } } }
identifier_body
insertion_sort.rs
#![doc="Insertion sort algorithms "] // std imports use std::ptr; /// Performs insertion sort on a slice of type T pub fn insertion_sort_slice<T : PartialOrd>(data : &mut [T]){ let n = data.len(); for j in (1..n){ // we insert data[j] into the sorted sequence //data[0...j-1] let mut ...
i -= 1; di = di.offset(-1); dj = dj.offset(-1); } } } /****************************************************** * * Unit tests * *******************************************************/ #[cfg(test)] mod test{ use super::*; use alg::sort::*; #[test] ...
{ break; }
conditional_block
ffi.rs
// Silence invalid warnings due to rust-lang/rust#16719 #![allow(improper_ctypes)] use libc::{c_int, c_void, socklen_t, ssize_t}; pub use libc::{socket, listen, bind, accept, connect, setsockopt, sendto, recvfrom, getsockname, getpeername, recv, send};
level: c_int, optname: c_int, optval: *mut c_void, optlen: *mut socklen_t) -> c_int; pub fn socketpair( domain: c_int, typ: c_int, protocol: c_int, sv: *mut c_int ) -> c_int; pub fn sendmsg(sockfd: c_int, msg: *const msgh...
use super::msghdr; extern { pub fn getsockopt( sockfd: c_int,
random_line_split
mrow.rs
/* * Copyright 2017 Sreejith Krishnan R * * 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...
} } let mut wrapper = self.presentation_element.layout(context); wrapper.wrap(layout); wrapper.calculate(context, &MeasureMode::Wrap, &MeasureMode::Wrap); wrapper } } impl MrowLayout { pub fn new(dir: Directionality, math_color: Color, math_background: Colo...
MrowLayout::get_linear_layout_params_for_element(element.as_ref())); }, Directionality::RTL => for element in self.elements.iter().rev() { layout.add_child(element.layout(context), MrowLayout::get_linear_layout_par...
random_line_split
mrow.rs
/* * Copyright 2017 Sreejith Krishnan R * * 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...
<'a>(&'a self, context: &Context) -> Box<Drawable + 'a> { Box::new(ConcreteLayout::layout(self, context)) } fn as_any(&self) -> &Any { self } fn as_any_mut(&mut self) -> &mut Any { self } } impl ElementGroup for MrowLayout { fn children(&self) -> &[Box<Layout>] { ...
layout
identifier_name
mrow.rs
/* * Copyright 2017 Sreejith Krishnan R * * 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...
} impl ElementGroup for MrowLayout { fn children(&self) -> &[Box<Layout>] { &self.elements[..] } } impl<'a> ConcreteLayout<'a, Wrapper<'a, PresentationLayout, LinearLayout<'a>>> for MrowLayout { fn layout(&'a self, context: &Context) -> Wrapper<'a, PresentationLayout, LinearLayout<'a>> { ...
{ self }
identifier_body
mrow.rs
/* * Copyright 2017 Sreejith Krishnan R * * 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...
} return LinearLayoutParams::new(); } } #[cfg(test)] mod test { use super::*; use super::super::super::{MiLayout}; use ::props::{MathVariant}; #[test] fn mrow_works() { let mut mrow = MrowLayout::new(Directionality::LTR, Color::R...
{ return LinearLayoutParams::new() .with_cross_axis_bound_mode(CrossAxisBoundMode::FillParent) .with_weight(1f32); }
conditional_block
bench.rs
#![feature(test)] extern crate test; extern crate rand; mod distributions; use test::Bencher; use rand::{weak_rng, Rng}; pub const RAND_BENCH_N: u64 = 100; #[bench] fn rand_shuffle_100(b: &mut Bencher) { let mut rng = weak_rng(); let x : &mut [usize] = &mut [1; 100]; b.iter(|| { rng.shuffle(x) ...
black_box(rng.gen::<usize>()); } }); b.bytes = size_of::<usize>() as u64 * RAND_BENCH_N; } }
fn rand_weak(b: &mut Bencher) { let mut rng = weak_rng(); b.iter(|| { for _ in 0..RAND_BENCH_N {
random_line_split
bench.rs
#![feature(test)] extern crate test; extern crate rand; mod distributions; use test::Bencher; use rand::{weak_rng, Rng}; pub const RAND_BENCH_N: u64 = 100; #[bench] fn rand_shuffle_100(b: &mut Bencher) { let mut rng = weak_rng(); let x : &mut [usize] = &mut [1; 100]; b.iter(|| { rng.shuffle(x) ...
#[bench] fn rand_weak(b: &mut Bencher) { let mut rng = weak_rng(); b.iter(|| { for _ in 0..RAND_BENCH_N { black_box(rng.gen::<usize>()); } }); b.bytes = size_of::<usize>() as u64 * RAND_BENCH_N; } }
{ let mut rng = StdRng::new().unwrap(); b.iter(|| { for _ in 0..RAND_BENCH_N { black_box(rng.gen::<usize>()); } }); b.bytes = size_of::<usize>() as u64 * RAND_BENCH_N; }
identifier_body
bench.rs
#![feature(test)] extern crate test; extern crate rand; mod distributions; use test::Bencher; use rand::{weak_rng, Rng}; pub const RAND_BENCH_N: u64 = 100; #[bench] fn rand_shuffle_100(b: &mut Bencher) { let mut rng = weak_rng(); let x : &mut [usize] = &mut [1; 100]; b.iter(|| { rng.shuffle(x) ...
(b: &mut Bencher) { let mut rng = weak_rng(); b.iter(|| { for _ in 0..RAND_BENCH_N { black_box(rng.gen::<usize>()); } }); b.bytes = size_of::<usize>() as u64 * RAND_BENCH_N; } }
rand_weak
identifier_name
actor.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/. */ /// General actor system infrastructure. use devtools_traits::PreciseTime; use rustc_serialize::json; use std::an...
(&self) -> PreciseTime { self.start_stamp.clone() } pub fn register_script_actor(&self, script_id: String, actor: String) { println!("registering {} ({})", actor, script_id); let mut script_actors = self.script_actors.borrow_mut(); script_actors.insert(script_id, actor); } ...
start_stamp
identifier_name
actor.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/. */ /// General actor system infrastructure. use devtools_traits::PreciseTime; use rustc_serialize::json; use std::an...
self.script_actors.borrow().get(&script_id).unwrap().clone() } pub fn script_actor_registered(&self, script_id: String) -> bool { self.script_actors.borrow().contains_key(&script_id) } pub fn actor_to_script(&self, actor: String) -> String { for (key, value) in &*self.script_a...
{ return "".to_owned(); }
conditional_block
actor.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/. */ /// General actor system infrastructure. use devtools_traits::PreciseTime; use rustc_serialize::json; use std::an...
} pub fn register_later(&self, actor: Box<Actor + Send>) { let mut actors = self.new_actors.borrow_mut(); actors.push(actor); } /// Find an actor by registered name pub fn find<'a, T: Any>(&'a self, name: &str) -> &'a T { let actor = self.actors.get(name).unwrap(); ...
/// Add an actor to the registry of known actors that can receive messages. pub fn register(&mut self, actor: Box<Actor + Send>) { self.actors.insert(actor.name(), actor);
random_line_split
lib.rs
#![crate_name = "graphics"] #![deny(missing_docs)] #![deny(missing_copy_implementations)] //! A library for 2D graphics that works with multiple back-ends. extern crate vecmath as vecmath_lib; extern crate texture; extern crate read_color; extern crate interpolation; extern crate draw_state as draw_state_lib; extern ...
pub use rectangled::Rectangled; pub use transformed::Transformed; pub use colored::Colored; pub use rectangle::Rectangle; pub use line::Line; pub use ellipse::Ellipse; pub use image::Image; pub use polygon::Polygon; pub use text::Text; pub use default_draw_state::default_draw_state; pub use clip_draw_state::clip_draw_s...
pub use viewport::Viewport; pub use graphics::Graphics; pub use source_rectangled::SourceRectangled;
random_line_split
lib.rs
#![crate_name = "graphics"] #![deny(missing_docs)] #![deny(missing_copy_implementations)] //! A library for 2D graphics that works with multiple back-ends. extern crate vecmath as vecmath_lib; extern crate texture; extern crate read_color; extern crate interpolation; extern crate draw_state as draw_state_lib; extern ...
/// Draws ellipse. pub fn ellipse<R: Into<types::Rectangle>, G>( color: types::Color, rect: R, transform: math::Matrix2d, g: &mut G ) where G: Graphics { Ellipse::new(color).draw(rect, default_draw_state(), transform, g); } /// Draws rectangle. pub fn rectangle<R: Into<types::Rectangle>, G>( ...
{ Image::new().draw(image, default_draw_state(), transform, g); }
identifier_body
lib.rs
#![crate_name = "graphics"] #![deny(missing_docs)] #![deny(missing_copy_implementations)] //! A library for 2D graphics that works with multiple back-ends. extern crate vecmath as vecmath_lib; extern crate texture; extern crate read_color; extern crate interpolation; extern crate draw_state as draw_state_lib; extern ...
<G>( color: types::Color, g: &mut G ) where G: Graphics { g.clear_color(color); } /// Draws image. pub fn image<G>( image: &<G as Graphics>::Texture, transform: math::Matrix2d, g: &mut G ) where G: Graphics { Image::new().draw(image, default_draw_state(), transform, g); } /// Draws ell...
clear
identifier_name
graph_map.rs
use typed_map::TypedMemoryMap; pub struct GraphMMap { nodes: TypedMemoryMap<u64>, edges: TypedMemoryMap<u32>, } impl GraphMMap { #[inline(always)] pub fn nodes(&self) -> usize
#[inline(always)] pub fn edges(&self, node: usize) -> &[u32] { let nodes = &self.nodes[..]; if node + 1 < nodes.len() { let start = nodes[node] as usize; let limit = nodes[node+1] as usize; &self.edges[..][start..limit] } else { &[] } } ...
{ self.nodes[..].len() }
identifier_body
graph_map.rs
use typed_map::TypedMemoryMap; pub struct GraphMMap { nodes: TypedMemoryMap<u64>, edges: TypedMemoryMap<u32>, } impl GraphMMap { #[inline(always)] pub fn nodes(&self) -> usize { self.nodes[..].len() } #[inline(always)] pub fn edges(&self, node: usize) -> &[u32] { let nodes = &self.node...
} } }
random_line_split