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
tests.rs
extern crate arrayvec; use arrayvec::ArrayVec; use std::mem; #[test] fn test_simple() { use std::ops::Add; let mut vec: ArrayVec<[Vec<i32>; 3]> = ArrayVec::new(); vec.push(vec![1, 2, 3, 4]); vec.push(vec![10]); vec.push(vec![-1, 13, -2]); for elt in &vec { assert_eq!(elt.iter().fol...
#[test] fn test_insert() { let mut v = ArrayVec::from([]); assert_eq!(v.push(1), Some(1)); assert_eq!(v.insert(0, 1), Some(1)); let mut v = ArrayVec::<[_; 3]>::new(); v.insert(0, 0); v.insert(1, 1); v.insert(2, 2); v.insert(3, 3); assert_eq!(&v[..], &[0, 1, 2]); v.insert(1, 9)...
{ let mut v = ArrayVec::from([0; 8]); v.pop(); v.drain(0..8); }
identifier_body
exposure.rs
/* * Copyright (C) 2012 The Android Open Source Project * * 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 app...
out.rgb = convert_uchar3(clamp(convert_int3(t * bright), 0, 255)); return out; }
uchar4 RS_KERNEL exposure(uchar4 in) { uchar4 out = {0, 0, 0, 255}; float3 t = convert_float3(in.rgb);
random_line_split
stream.rs
/*-------------------------------------------------------------------------- smoke-rs The MIT License (MIT) Copyright (c) 2016 Haydn Paterson (sinclair) <haydn.developer@gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (t...
rx } /// Will merge multiple streams into a single stream. /// # Example /// /// ``` /// use smoke::async::Stream; /// /// let a = Stream::range(0, 4); /// let b = Stream::range(4, 8); /// let c = Stream::merge(vec![a, b]); /// for n in c.read() { /// // 0, 1, 2, 3, 4, 5, 6, 7 //...
let (tx, rx) = sync_channel(bound); let _ = thread::spawn(move || self.func.call(tx));
random_line_split
stream.rs
/*-------------------------------------------------------------------------- smoke-rs The MIT License (MIT) Copyright (c) 2016 Haydn Paterson (sinclair) <haydn.developer@gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (t...
(self) -> StreamReceiver<T> { let (tx, rx) = sync_channel(1); let _ = thread::spawn(move || self.func.call(tx)); rx } /// Reads elements from the stream with a bound. /// # Example /// /// ``` /// use smoke::async::Stream; /// /// for n in Stream::range(0, 4).read() { /// // 0...
read
identifier_name
stream.rs
/*-------------------------------------------------------------------------- smoke-rs The MIT License (MIT) Copyright (c) 2016 Haydn Paterson (sinclair) <haydn.developer@gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (t...
/// Will merge multiple streams into a single stream. /// # Example /// /// ``` /// use smoke::async::Stream; /// /// let a = Stream::range(0, 4); /// let b = Stream::range(4, 8); /// let c = Stream::merge(vec![a, b]); /// for n in c.read() { /// // 0, 1, 2, 3, 4, 5, 6, 7 /// } /// ``...
{ let (tx, rx) = sync_channel(bound); let _ = thread::spawn(move || self.func.call(tx)); rx }
identifier_body
associated-types-ref-in-struct-literal.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. //
// except according to those terms. // run-pass // Test associated type references in a struct literal. Issue #20535. pub trait Foo { type Bar; fn dummy(&self) { } } impl Foo for isize { type Bar = isize; } struct Thing<F: Foo> { a: F, b: F::Bar, } fn main() { let thing = Thing{a: 1, b: 2...
// 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
random_line_split
associated-types-ref-in-struct-literal.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 thing = Thing{a: 1, b: 2}; assert_eq!(thing.a + 1, thing.b); }
identifier_body
associated-types-ref-in-struct-literal.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 ...
<F: Foo> { a: F, b: F::Bar, } fn main() { let thing = Thing{a: 1, b: 2}; assert_eq!(thing.a + 1, thing.b); }
Thing
identifier_name
vu.rs
// Copyright (C) 2009 The Android Open Source Project // // 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 applic...
#pragma rs java_package_name(com.android.musicvis.vis4) #include "rs_graphics.rsh" // State float gAngle; int gPeak; rs_program_vertex gPVBackground; rs_program_fragment gPFBackground; rs_allocation gTvumeter_background; rs_allocation gTvumeter_peak_on; rs_allocation gTvumeter_peak_off; rs_allocation gTvumeter_n...
#pragma version(1)
random_line_split
vu.rs
// Copyright (C) 2009 The Android Open Source Project // // 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 applic...
else { rsgBindTexture(gPFBackground, 0, gTvumeter_peak_off); } rsgDrawQuadTexCoords( 140.0f, 70.0f, -1.0f, // space 0.0, 1.0f, // texture 196, 70.0f, -1.0f, // space 1.0f, 1.0f, // texture ...
{ rsgBindTexture(gPFBackground, 0, gTvumeter_peak_on); }
conditional_block
rust_base58.rs
extern crate rust_base58; use errors::prelude::*; use self::rust_base58::{FromBase58, ToBase58}; pub fn
(doc: &[u8]) -> String { doc.to_base58() } pub fn decode(doc: &str) -> Result<Vec<u8>, IndyError> { doc.from_base58() .map_err(|err| err_msg(IndyErrorKind::InvalidStructure, format!("Invalid base58 sequence: {:}", err))) } #[cfg(test)] mod tests { use super::*; #[test] fn encode_works() { ...
encode
identifier_name
rust_base58.rs
extern crate rust_base58; use errors::prelude::*; use self::rust_base58::{FromBase58, ToBase58}; pub fn encode(doc: &[u8]) -> String { doc.to_base58() } pub fn decode(doc: &str) -> Result<Vec<u8>, IndyError> { doc.from_base58() .map_err(|err| err_msg(IndyErrorKind::InvalidStructure, format!("Invalid b...
#[test] fn decode_works() { let result = decode("Ldp"); assert!(result.is_ok(), "Got error"); assert_eq!(&[1, 2, 3], &result.unwrap()[..], "Get unexpected data"); } }
{ let result = encode(&[1, 2, 3]); assert_eq!("Ldp", &result, "Got unexpected data"); }
identifier_body
rust_base58.rs
extern crate rust_base58;
pub fn encode(doc: &[u8]) -> String { doc.to_base58() } pub fn decode(doc: &str) -> Result<Vec<u8>, IndyError> { doc.from_base58() .map_err(|err| err_msg(IndyErrorKind::InvalidStructure, format!("Invalid base58 sequence: {:}", err))) } #[cfg(test)] mod tests { use super::*; #[test] fn enco...
use errors::prelude::*; use self::rust_base58::{FromBase58, ToBase58};
random_line_split
debug.rs
use core::sync::atomic::{AtomicUsize, Ordering}; use spin::{Once, RwLock, RwLockReadGuard, RwLockWriteGuard}; use crate::arch::debug::Writer; use crate::event; use crate::scheme::*; use crate::sync::WaitQueue; use crate::syscall::flag::{EventFlags, EVENT_READ, F_GETFL, F_SETFL, O_ACCMODE, O_NONBLOCK}; use crate::sysca...
() -> RwLockReadGuard<'static, BTreeMap<usize, Handle>> { HANDLES.call_once(init_handles).read() } fn handles_mut() -> RwLockWriteGuard<'static, BTreeMap<usize, Handle>> { HANDLES.call_once(init_handles).write() } /// Add to the input queue pub fn debug_input(data: u8) { INPUT.call_once(init_input).send(d...
handles
identifier_name
debug.rs
use core::sync::atomic::{AtomicUsize, Ordering}; use spin::{Once, RwLock, RwLockReadGuard, RwLockWriteGuard}; use crate::arch::debug::Writer; use crate::event; use crate::scheme::*; use crate::sync::WaitQueue; use crate::syscall::flag::{EventFlags, EVENT_READ, F_GETFL, F_SETFL, O_ACCMODE, O_NONBLOCK}; use crate::sysca...
else { Err(Error::new(EBADF)) } } fn fevent(&self, id: usize, _flags: EventFlags) -> Result<EventFlags> { let _handle = { let handles = handles(); *handles.get(&id).ok_or(Error::new(EBADF))? }; Ok(EventFlags::empty()) } fn fpath(&se...
{ match cmd { F_GETFL => Ok(handle.flags), F_SETFL => { handle.flags = arg & ! O_ACCMODE; Ok(0) }, _ => Err(Error::new(EINVAL)) } }
conditional_block
debug.rs
use core::sync::atomic::{AtomicUsize, Ordering}; use spin::{Once, RwLock, RwLockReadGuard, RwLockWriteGuard}; use crate::arch::debug::Writer; use crate::event; use crate::scheme::*; use crate::sync::WaitQueue; use crate::syscall::flag::{EventFlags, EVENT_READ, F_GETFL, F_SETFL, O_ACCMODE, O_NONBLOCK}; use crate::sysca...
/// Write the `buffer` to the `file` /// /// Returns the number of bytes written fn write(&self, id: usize, buf: &[u8]) -> Result<usize> { let _handle = { let handles = handles(); *handles.get(&id).ok_or(Error::new(EBADF))? }; Writer::new().write(buf); ...
.receive_into(buf, handle.flags & O_NONBLOCK != O_NONBLOCK, "DebugScheme::read") .ok_or(Error::new(EINTR)) }
random_line_split
debug.rs
use core::sync::atomic::{AtomicUsize, Ordering}; use spin::{Once, RwLock, RwLockReadGuard, RwLockWriteGuard}; use crate::arch::debug::Writer; use crate::event; use crate::scheme::*; use crate::sync::WaitQueue; use crate::syscall::flag::{EventFlags, EVENT_READ, F_GETFL, F_SETFL, O_ACCMODE, O_NONBLOCK}; use crate::sysca...
// Notify readers of input updates pub fn debug_notify() { for (id, _handle) in handles().iter() { event::trigger(SCHEME_ID.load(Ordering::SeqCst), *id, EVENT_READ); } } pub struct DebugScheme; impl DebugScheme { pub fn new(scheme_id: SchemeId) -> Self { SCHEME_ID.store(scheme_id, Orderi...
{ INPUT.call_once(init_input).send(data); }
identifier_body
system.rs
// Copyright 2014 The sdl2-rs Developers. // // 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 a...
}
random_line_split
phantom.rs
// https://rustbyexample.com/generics/phantom.html // http://rust-lang-ja.org/rust-by-example/generics/phantom.html use std::marker::PhantomData; // A phantom tuple struct which is generic over `A` with hidden parameter `B`. #[derive(PartialEq)] // Allow equality test for this type. struct PhantomTuple<A, B>(A, Phant...
() { // here, `f32` and `f64` are the hidden parameters. // PhantomTuple type specified as `<char, f32>`. let _tuple1: PhantomTuple<char, f32> = PhantomTuple('Q', PhantomData); // PhantomTuple type specified as `<char, f64>`. let _tuple2: PhantomTuple<char, f64> = PhantomTuple('Q', PhantomData); ...
main
identifier_name
phantom.rs
// https://rustbyexample.com/generics/phantom.html
// http://rust-lang-ja.org/rust-by-example/generics/phantom.html use std::marker::PhantomData; // A phantom tuple struct which is generic over `A` with hidden parameter `B`. #[derive(PartialEq)] // Allow equality test for this type. struct PhantomTuple<A, B>(A, PhantomData<B>); // A phantom type struct which is gene...
random_line_split
lib.rs
/* * Copyright 2015-2017 Two Pore Guys, Inc. * All rights reserved * * Redistribution and use in source and binary forms, with or without * modification, are permitted providing that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of...
} } } impl std::hash::Hash for Object { fn hash<H: std::hash::Hasher>(&self, state: &mut H) { } } impl fmt::Debug for Object { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { unsafe { let descr = rpc_copy_description(self.value); let str = CString::from_...
RawType::Dictionary => Value::Null, RawType::Error => Value::Null, }
random_line_split
lib.rs
/* * Copyright 2015-2017 Two Pore Guys, Inc. * All rights reserved * * Redistribution and use in source and binary forms, with or without * modification, are permitted providing that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of...
(value: &str) -> Value { Value::String(String::from(value)) } } impl From<String> for Value { fn from(value: String) -> Value { Value::String(value) } } impl From<Vec<u8>> for Value { fn from(value: Vec<u8>) -> Value { Value::Binary(value) } } impl<'a> From<&'a [Value]> fo...
from
identifier_name
object-lifetime-default-default-to-static.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 ...
(t: Box<Test+'static>, mut ss: SomeStruct) { ss.u = t; } fn main() { }
d
identifier_name
object-lifetime-default-default-to-static.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 ...
ss.u = t; } fn d(t: Box<Test+'static>, mut ss: SomeStruct) { ss.u = t; } fn main() { }
fn c(t: Box<Test>, mut ss: SomeStruct) {
random_line_split
object-lifetime-default-default-to-static.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 ...
fn d(t: Box<Test+'static>, mut ss: SomeStruct) { ss.u = t; } fn main() { }
{ ss.u = t; }
identifier_body
struct-style-enum.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
() {()}
zzz
identifier_name
struct-style-enum.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...
// 0b0101100101011001 = 22873 // 0b01011001 = 89 let case3 = Case3 { a: 0, b: 6438275382588823897 }; let univariant = TheOnlyCase { a: -1 }; zzz(); // #break } fn zzz() {()}
{ // In order to avoid endianness trouble all of the following test values consist of a single // repeated byte. This way each interpretation of the union should look the same, no matter if // this is a big or little endian machine. // 0b0111110001111100011111000111110001111100011111000111110001111100...
identifier_body
struct-style-enum.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
// gdb-command:print case3 // gdb-check:$3 = {{RUST$ENUM$DISR = Case3, a = 0, b = 22873, c = 22873, d = 22873, e = 22873}, {RUST$ENUM$DISR = Case3, a = 0, b = 1499027801, c = 1499027801}, {RUST$ENUM$DISR = Case3, a = 0, b = 6438275382588823897}} // gdb-command:print univariant // gdb-check:$4 = {{a = -1}} // === LLD...
// gdb-command:print case2 // gdb-check:$2 = {{RUST$ENUM$DISR = Case2, a = 0, b = 4369, c = 4369, d = 4369, e = 4369}, {RUST$ENUM$DISR = Case2, a = 0, b = 286331153, c = 286331153}, {RUST$ENUM$DISR = Case2, a = 0, b = 1229782938247303441}}
random_line_split
button.rs
#![feature(used)] #![no_std] extern crate cortex_m; extern crate panic_abort; extern crate stm32f30x_hal as hal; use hal::prelude::*; use hal::stm32f30x; use hal::spi::Spi; fn main() { let cp = cortex_m::Peripherals::take().unwrap(); let dp = stm32f30x::Peripherals::take().unwrap(); let mut flash = dp.F...
} }
{ led.set_high(); }
conditional_block
button.rs
#![feature(used)] #![no_std] extern crate cortex_m; extern crate panic_abort; extern crate stm32f30x_hal as hal; use hal::prelude::*; use hal::stm32f30x; use hal::spi::Spi; fn
() { let cp = cortex_m::Peripherals::take().unwrap(); let dp = stm32f30x::Peripherals::take().unwrap(); let mut flash = dp.FLASH.constrain(); let mut rcc = dp.RCC.constrain(); let clocks = rcc.cfgr.freeze(&mut flash.acr); let mut gpiob = dp.GPIOB.split(&mut rcc.ahb); let mut gpioc = dp.GP...
main
identifier_name
button.rs
#![feature(used)] #![no_std] extern crate cortex_m; extern crate panic_abort; extern crate stm32f30x_hal as hal; use hal::prelude::*; use hal::stm32f30x; use hal::spi::Spi; fn main() { let cp = cortex_m::Peripherals::take().unwrap();
let clocks = rcc.cfgr.freeze(&mut flash.acr); let mut gpiob = dp.GPIOB.split(&mut rcc.ahb); let mut gpioc = dp.GPIOC.split(&mut rcc.ahb); // Set up Pins let mut button = gpiob.pb8 .into_pull_up_input(&mut gpiob.moder, &mut gpiob.pupdr); let mut led = gpioc.pc13 .into_push_pu...
let dp = stm32f30x::Peripherals::take().unwrap(); let mut flash = dp.FLASH.constrain(); let mut rcc = dp.RCC.constrain();
random_line_split
button.rs
#![feature(used)] #![no_std] extern crate cortex_m; extern crate panic_abort; extern crate stm32f30x_hal as hal; use hal::prelude::*; use hal::stm32f30x; use hal::spi::Spi; fn main()
led.set_low(); } else { led.set_high(); } } }
{ let cp = cortex_m::Peripherals::take().unwrap(); let dp = stm32f30x::Peripherals::take().unwrap(); let mut flash = dp.FLASH.constrain(); let mut rcc = dp.RCC.constrain(); let clocks = rcc.cfgr.freeze(&mut flash.acr); let mut gpiob = dp.GPIOB.split(&mut rcc.ahb); let mut gpioc = dp.GPIOC...
identifier_body
ref_cell.rs
// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. use core::marker::{Sync, NoSend, PhantomData, Send}; use core::ops::{Deref, DerefMut, Drop}; use cell::{Cell}; /// T...
<'a, T:?Sized+'a> { cell: &'a RefCell<T>, _marker: NoSend, } unsafe impl<'a, T: Sync+?Sized> Sync for RefCellBorrow<'a, T> { } impl<'a, T:?Sized> Deref for RefCellBorrow<'a, T> { type Target = T; fn deref(&self) -> &T { &self.cell.inner().data } } impl<'a, T:?Sized> Drop for RefCellBorrow...
RefCellBorrow
identifier_name
ref_cell.rs
// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. use core::marker::{Sync, NoSend, PhantomData, Send}; use core::ops::{Deref, DerefMut, Drop}; use cell::{Cell}; /// T...
impl<'a, T:?Sized> Deref for RefCellBorrow<'a, T> { type Target = T; fn deref(&self) -> &T { &self.cell.inner().data } } impl<'a, T:?Sized> Drop for RefCellBorrow<'a, T> { fn drop(&mut self) { let inner = self.cell.inner(); inner.status = match inner.status { RefCell...
unsafe impl<'a, T: Sync+?Sized> Sync for RefCellBorrow<'a, T> { }
random_line_split
places_sidebar.rs
// This file is part of rgtk. // // rgtk 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 Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
self, show_desktop: bool) { unsafe { ffi::gtk_places_sidebar_set_show_desktop(GTK_PLACES_SIDEBAR(self.unwrap_widget()), to_gboolean(show_desktop)) } } pub fn get_show_desktop(&self) -> bool { unsafe { to_bool(ffi::gtk_places_sidebar_get_show_desktop(GTK_PLACES_SIDEBAR(self.unwrap_widget()))) } ...
t_show_desktop(&
identifier_name
places_sidebar.rs
// This file is part of rgtk. // // rgtk 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 Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
pub fn get_show_enter_location(&self) -> bool { unsafe { to_bool(ffi::gtk_places_sidebar_get_show_enter_location(GTK_PLACES_SIDEBAR(self.unwrap_widget()))) } } } impl_drop!(PlacesSidebar); impl_TraitWidget!(PlacesSidebar); impl gtk::ContainerTrait for PlacesSidebar {} impl gtk::BinTrait for PlacesSide...
unsafe { ffi::gtk_places_sidebar_set_show_enter_location(GTK_PLACES_SIDEBAR(self.unwrap_widget()), to_gboolean(show_enter_location)) } }
identifier_body
places_sidebar.rs
// This file is part of rgtk. // // rgtk 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 Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
use gtk::{self, ffi}; use gtk::FFIWidget; use gtk::cast::GTK_PLACES_SIDEBAR; use glib::{to_bool, to_gboolean}; struct_Widget!(PlacesSidebar); impl PlacesSidebar { pub fn new() -> Option<PlacesSidebar> { let tmp_pointer = unsafe { ffi::gtk_places_sidebar_new() }; check_pointer!(tmp_pointer, PlacesS...
//! GtkPlacesSidebar — Sidebar that displays frequently-used places in the file system
random_line_split
mod.rs
// Copyright 2013 The rust-glib authors. // // 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 ac...
pub type gssize = libc::ssize_t; pub type gsize = libc::size_t; pub type gintptr = libc::intptr_t; pub type guintptr = libc::uintptr_t;
pub type guint64 = u64;
random_line_split
lib.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/. */ #![feature(alloc_jemalloc)] #![feature(box_syntax)]
#![deny(unsafe_code)] #[allow(unused_extern_crates)] #[cfg(not(target_os = "windows"))] extern crate alloc_jemalloc; extern crate hbs_pow; extern crate ipc_channel; extern crate libc; #[macro_use] extern crate log; #[macro_use] extern crate profile_traits; #[cfg(target_os = "linux")] extern crate regex; #[cfg(target_o...
#![feature(iter_arith)] #![feature(plugin)] #![plugin(plugins)]
random_line_split
error.rs
use std::c_str::CString; use std::error; use std::fmt; use std::str; use libc; use libc::c_int; use {raw, ErrorCode}; /// A structure to represent errors coming out of libgit2. pub struct Error { raw: raw::git_error, } impl Error { /// Returns the last error, or `None` if one is not available. pub fn las...
} impl error::Error for Error { fn description(&self) -> &str { unsafe { str::from_c_str(self.raw.message as *const _) } } fn detail(&self) -> Option<String> { Some(self.message()) } } impl fmt::Show for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { try!(write!(f, "[...
{ let cstr = unsafe { CString::new(self.raw.message as *const _, false) }; String::from_utf8_lossy(cstr.as_bytes_no_nul()).to_string() }
identifier_body
error.rs
use std::c_str::CString; use std::error; use std::fmt; use std::str; use libc; use libc::c_int; use {raw, ErrorCode}; /// A structure to represent errors coming out of libgit2. pub struct Error { raw: raw::git_error, } impl Error { /// Returns the last error, or `None` if one is not available. pub fn las...
GIT_EUSER, GIT_EBAREREPO, GIT_EUNBORNBRANCH, GIT_EUNMERGED, GIT_ENONFASTFORWARD, GIT_EINVALIDSPEC, GIT_EMERGECONFLICT, GIT_ELOCKED, GIT_EMODIFIED, GIT_PASSTHROUGH, GIT_ITEROVER ) ...
GIT_ERROR, GIT_ENOTFOUND, GIT_EEXISTS, GIT_EAMBIGUOUS, GIT_EBUFS,
random_line_split
error.rs
use std::c_str::CString; use std::error; use std::fmt; use std::str; use libc; use libc::c_int; use {raw, ErrorCode}; /// A structure to represent errors coming out of libgit2. pub struct Error { raw: raw::git_error, } impl Error { /// Returns the last error, or `None` if one is not available. pub fn las...
(&self) -> &str { unsafe { str::from_c_str(self.raw.message as *const _) } } fn detail(&self) -> Option<String> { Some(self.message()) } } impl fmt::Show for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { try!(write!(f, "[{}] ", self.raw.klass)); let cstr = unsafe {...
description
identifier_name
linked-list.rs
use vec_arena::Arena; /// The null index, akin to null pointers. /// /// Just like a null pointer indicates an address no object is ever stored at, /// the null index indicates an index no object is ever stored at. /// /// Number `!0` is the largest possible value representable by `usize`. const NULL: usize =!0; stru...
assert!(list.remove(one) == 1); assert!(list.remove(twenty) == 20); // The list is now [2, 3, 10, 30]. assert!(list.len() == 4); assert!(list.pop_front() == 2); assert!(list.pop_front() == 3); assert!(list.pop_front() == 10); assert!(list.pop_front() == 30); // The list is now []...
assert!(list.len() == 6);
random_line_split
linked-list.rs
use vec_arena::Arena; /// The null index, akin to null pointers. /// /// Just like a null pointer indicates an address no object is ever stored at, /// the null index indicates an index no object is ever stored at. /// /// Number `!0` is the largest possible value representable by `usize`. const NULL: usize =!0; stru...
<T> { /// Previous node in the list. prev: usize, /// Next node in the list. next: usize, /// Actual value stored in node. value: T, } struct List<T> { /// This is where nodes are stored. arena: Arena<Node<T>>, /// First node in the list. head: usize, /// Last node in th...
Node
identifier_name
linked-list.rs
use vec_arena::Arena; /// The null index, akin to null pointers. /// /// Just like a null pointer indicates an address no object is ever stored at, /// the null index indicates an index no object is ever stored at. /// /// Number `!0` is the largest possible value representable by `usize`. const NULL: usize =!0; stru...
if b!= NULL { self.arena[b].prev = a; } } /// Appends `value` to the back of the list. fn push_back(&mut self, value: T) -> usize { let node = self.arena.insert(Node { prev: NULL, next: NULL, value: value, }); let tai...
{ self.arena[a].next = b; }
conditional_block
linked-list.rs
use vec_arena::Arena; /// The null index, akin to null pointers. /// /// Just like a null pointer indicates an address no object is ever stored at, /// the null index indicates an index no object is ever stored at. /// /// Number `!0` is the largest possible value representable by `usize`. const NULL: usize =!0; stru...
/// Links nodes `a` and `b` together, so that `a` comes before `b` in the list. fn link(&mut self, a: usize, b: usize) { if a!= NULL { self.arena[a].next = b; } if b!= NULL { self.arena[b].prev = a; } } /// Appends `value` to the back of the lis...
{ self.arena.len() }
identifier_body
poller.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 crate::{ agent_error::ImlAgentError, http_comms::{ agent_client::AgentClient, session::{Sessions, State}, }, }; use futures::{future, F...
name: PluginName, now: Instant, ) -> impl Future<Output = Result<(), ImlAgentError>> { tracing::trace!("handling state for {:?}: {:?}, ", name, state); match state { State::Active(a) if a.instant <= now && a.in_flight.is_none() => { tracing::trace!("starting poll for {:?}:", name); ...
sessions: Sessions,
random_line_split
poller.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 crate::{ agent_error::ImlAgentError, http_comms::{ agent_client::AgentClient, session::{Sessions, State}, }, }; use futures::{future, F...
match r { Ok(_) => { sessions.reset_active(&name).await; Ok(()) } Err(_) => sessions.terminate_session(&name, &id).await, } }) .boxed() } Sta...
{ tracing::trace!("handling state for {:?}: {:?}, ", name, state); match state { State::Active(a) if a.instant <= now && a.in_flight.is_none() => { tracing::trace!("starting poll for {:?}:", name); let (rx, fut) = a.session.poll(); a.in_flight = Some(rx); ...
identifier_body
poller.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 crate::{ agent_error::ImlAgentError, http_comms::{ agent_client::AgentClient, session::{Sessions, State}, }, }; use futures::{future, F...
Err(_) => sessions.terminate_session(&name, &id).await, } }) .boxed() } State::Active(a) if a.instant + a.session.deadline() <= now && a.in_flight.is_some() => { tracing::trace!("Dropping poll for {:?}; deadline exceeded", name); ...
{ sessions.reset_active(&name).await; Ok(()) }
conditional_block
poller.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 crate::{ agent_error::ImlAgentError, http_comms::{ agent_client::AgentClient, session::{Sessions, State}, }, }; use futures::{future, F...
( state: &mut State, agent_client: AgentClient, sessions: Sessions, name: PluginName, now: Instant, ) -> impl Future<Output = Result<(), ImlAgentError>> { tracing::trace!("handling state for {:?}: {:?}, ", name, state); match state { State::Active(a) if a.instant <= now && a.in_flig...
handle_state
identifier_name
physics.rs
use std::collections::HashMap; use cgmath::{EuclideanVector}; use specs; use world as w; const CELL_SIZE: f32 = 1.0; const OFFSETS: [(i32, i32); 9] = [(0, 0), (1, 0), (0, 1), (-1, 0), (0, -1), (1, 1), (1, -1), (-1, 1), (-1, -1)]; #[derive(Debug, Eq, Hash, PartialEq)] pub struct Cell(i32, i32); pub struct Sy...
} // clean up and delete more stuff for (_, vec) in self.grid.iter_mut() { for (e, damage) in vec.drain(..) { let c = collision.get_mut(e).unwrap(); if c.health > damage { c.health -= damage; }else { ...
{ arg.delete(ent); }
conditional_block
physics.rs
use std::collections::HashMap; use cgmath::{EuclideanVector}; use specs; use world as w; const CELL_SIZE: f32 = 1.0; const OFFSETS: [(i32, i32); 9] = [(0, 0), (1, 0), (0, 1), (-1, 0), (0, -1), (1, 1), (1, -1), (-1, 1), (-1, -1)]; #[derive(Debug, Eq, Hash, PartialEq)] pub struct Cell(i32, i32); pub struct Sy...
() -> System { System { grid: HashMap::new(), } } } impl specs::System<super::Delta> for System { fn run(&mut self, arg: specs::RunArg, _: super::Delta) { use specs::Join; let mut empty = Vec::new(); let (space, mut collision, entities) = arg.fetch(|w| ...
new
identifier_name
physics.rs
use std::collections::HashMap; use cgmath::{EuclideanVector}; use specs; use world as w; const CELL_SIZE: f32 = 1.0; const OFFSETS: [(i32, i32); 9] = [(0, 0), (1, 0), (0, 1), (-1, 0), (0, -1), (1, 1), (1, -1), (-1, 1), (-1, -1)]; #[derive(Debug, Eq, Hash, PartialEq)] pub struct Cell(i32, i32); pub struct Sy...
}else { arg.delete(ent); } } // clean up and delete more stuff for (_, vec) in self.grid.iter_mut() { for (e, damage) in vec.drain(..) { let c = collision.get_mut(e).unwrap(); if c.health > damage { ...
} if col.health > damage { self.grid.entry(cell).or_insert(Vec::new()).push((ent, damage));
random_line_split
static-method-xcrate.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 result: int = read(~"5"); assert!(result == 5); assert!(readMaybeRenamed(~"false") == Some(false)); assert!(readMaybeRenamed(~"foo") == None::<bool>); }
identifier_body
static-method-xcrate.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 result: int = read(~"5"); assert!(result == 5); assert!(readMaybeRenamed(~"false") == Some(false)); assert!(readMaybeRenamed(~"foo") == None::<bool>); }
main
identifier_name
static-method-xcrate.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 http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // xfail-fast // aux-build:static-methods-crate.rs extern mod static_methods_crate; use...
random_line_split
values.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/. */ //! Helper types and traits for the handling of CSS values. use app_units::Au; use cssparser::{ParseError, Parser...
self.inner.write_str(s) } #[inline] fn write_char(&mut self, c: char) -> fmt::Result { if let Some(prefix) = self.prefix.take() { // See comment in `write_str`. if!prefix.is_empty() { self.inner.write_str(prefix)?; } } sel...
{ // We are going to write things, but first we need to write // the prefix that was set by `SequenceWriter::item`. if !prefix.is_empty() { self.inner.write_str(prefix)?; } }
conditional_block
values.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/. */ //! Helper types and traits for the handling of CSS values. use app_units::Au; use cssparser::{ParseError, Parser...
self.inner.write_str(s) } #[inline] fn write_char(&mut self, c: char) -> fmt::Result { if let Some(prefix) = self.prefix.take() { // See comment in `write_str`. if!prefix.is_empty() { self.inner.write_str(prefix)?; } } self...
if !prefix.is_empty() { self.inner.write_str(prefix)?; } }
random_line_split
values.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/. */ //! Helper types and traits for the handling of CSS values. use app_units::Au; use cssparser::{ParseError, Parser...
#[inline] fn write_item<F>(&mut self, f: F) -> fmt::Result where F: FnOnce(&mut CssWriter<'b, W>) -> fmt::Result { let old_prefix = self.inner.prefix; if old_prefix.is_none() { // If there is no prefix in the inner writer, a previous // call to this meth...
{ if inner.prefix.is_none() { // See comment in `item`. inner.prefix = Some(""); } Self { inner, separator } }
identifier_body
values.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/. */ //! Helper types and traits for the handling of CSS values. use app_units::Au; use cssparser::{ParseError, Parser...
(&self, parsing_mode: ParsingMode, val: f32) -> bool { if parsing_mode.allows_all_numeric_values() { return true; } match *self { AllowedNumericType::All => true, AllowedNumericType::NonNegative => val >= 0.0, AllowedNum...
is_ok
identifier_name
json_dumper.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
use rls_data::{self, Analysis, CompilationOptions, CratePreludeData, Def, DefKind, Impl, Import, MacroRef, Ref, RefKind, Relation}; use rls_span::{Column, Row}; #[derive(Debug)] pub struct Access { pub reachable: bool, pub public: bool, } pub struct JsonDumper<O: DumpOutput> { result: Analy...
random_line_split
json_dumper.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
}
{ self.result.impls.push(data); }
identifier_body
json_dumper.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<O: DumpOutput> { result: Analysis, config: Config, output: O, } pub trait DumpOutput { fn dump(&mut self, result: &Analysis); } pub struct WriteOutput<'b, W: Write + 'b> { output: &'b mut W, } impl<'b, W: Write> DumpOutput for WriteOutput<'b, W> { fn dump(&mut self, result: &Analysis) { ...
JsonDumper
identifier_name
json_dumper.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
if data.kind == DefKind::Mod && data.span.file_name.to_str().unwrap()!= data.value { // If the module is an out-of-line definition, then we'll make the // definition the first character in the module's file and turn // the declaration into a reference to it. let ...
{ return; }
conditional_block
blink.rs
extern crate firmata; extern crate serial; use firmata::*; use serial::*; use std::thread; fn main() { let mut sp = serial::open("/dev/ttyACM0").unwrap(); sp.reconfigure(&|settings| { settings.set_baud_rate(Baud57600).unwrap(); settings.set_char_size(Bits8); settings.set_parity(Parity...
}
random_line_split
blink.rs
extern crate firmata; extern crate serial; use firmata::*; use serial::*; use std::thread; fn
() { let mut sp = serial::open("/dev/ttyACM0").unwrap(); sp.reconfigure(&|settings| { settings.set_baud_rate(Baud57600).unwrap(); settings.set_char_size(Bits8); settings.set_parity(ParityNone); settings.set_stop_bits(Stop1); settings.set_flow_control(FlowNone); O...
main
identifier_name
blink.rs
extern crate firmata; extern crate serial; use firmata::*; use serial::*; use std::thread; fn main()
let mut i = 0; loop { thread::sleep_ms(400); println!("{}",i); b.digital_write(13, i); i ^= 1; } }
{ let mut sp = serial::open("/dev/ttyACM0").unwrap(); sp.reconfigure(&|settings| { settings.set_baud_rate(Baud57600).unwrap(); settings.set_char_size(Bits8); settings.set_parity(ParityNone); settings.set_stop_bits(Stop1); settings.set_flow_control(FlowNone); Ok((...
identifier_body
pycapsule.rs
use libc::{c_void, c_char, c_int}; use object::*; #[cfg_attr(windows, link(name="pythonXY"))] extern "C" { pub static mut PyCapsule_Type: PyTypeObject; } pub type PyCapsule_Destructor = unsafe extern "C" fn(o: *mut PyObject); #[inline] pub unsafe fn PyCapsule_CheckExact(ob: *mut PyObject) -> c_int { (Py_TYPE...
pub fn PyCapsule_GetPointer(capsule: *mut PyObject, name: *const c_char) -> *mut c_void; pub fn PyCapsule_GetDestructor(capsule: *mut PyObject) -> Option<PyCapsule_Destructor>; pub fn PyCapsule_GetName(capsule: *mut PyObject) -> *const c_char; pub fn PyCapsule_G...
random_line_split
pycapsule.rs
use libc::{c_void, c_char, c_int}; use object::*; #[cfg_attr(windows, link(name="pythonXY"))] extern "C" { pub static mut PyCapsule_Type: PyTypeObject; } pub type PyCapsule_Destructor = unsafe extern "C" fn(o: *mut PyObject); #[inline] pub unsafe fn
(ob: *mut PyObject) -> c_int { (Py_TYPE(ob) == &mut PyCapsule_Type) as c_int } #[cfg_attr(windows, link(name="pythonXY"))] extern "C" { pub fn PyCapsule_New(pointer: *mut c_void, name: *const c_char, destructor: Option<PyCapsule_Destructor>) -> *mut PyObject; ...
PyCapsule_CheckExact
identifier_name
pycapsule.rs
use libc::{c_void, c_char, c_int}; use object::*; #[cfg_attr(windows, link(name="pythonXY"))] extern "C" { pub static mut PyCapsule_Type: PyTypeObject; } pub type PyCapsule_Destructor = unsafe extern "C" fn(o: *mut PyObject); #[inline] pub unsafe fn PyCapsule_CheckExact(ob: *mut PyObject) -> c_int
#[cfg_attr(windows, link(name="pythonXY"))] extern "C" { pub fn PyCapsule_New(pointer: *mut c_void, name: *const c_char, destructor: Option<PyCapsule_Destructor>) -> *mut PyObject; pub fn PyCapsule_GetPointer(capsule: *mut PyObject, ...
{ (Py_TYPE(ob) == &mut PyCapsule_Type) as c_int }
identifier_body
compiler.rs
use frontend::scanner::{scan_into_iterator, Position, ScannerError, Token, TokenWithContext}; use num_traits::{FromPrimitive, ToPrimitive}; use std::iter::Peekable; use vm::bytecode::{BinaryOp, Chunk, Constant, OpCode}; #[derive(Debug)] pub enum ParsingError { /// The end of file has been reached but the parser ex...
/// associated with a token. It operates only according to their /// variant. /// /// This is generally used on the token peeked from the front of /// the iterator. This lookahead allows us to decide what to do next /// according to the "table" below. fn find_rule(token: &Token) -> (Preceden...
/// Note that this function doesn't care about the values possibly
random_line_split
compiler.rs
use frontend::scanner::{scan_into_iterator, Position, ScannerError, Token, TokenWithContext}; use num_traits::{FromPrimitive, ToPrimitive}; use std::iter::Peekable; use vm::bytecode::{BinaryOp, Chunk, Constant, OpCode}; #[derive(Debug)] pub enum ParsingError { /// The end of file has been reached but the parser ex...
/// Adds an opcode to the current chunk fn emit(&mut self, opcode: OpCode, line: usize) -> () { self.chunk.add_instruction(opcode, line) } /// Peeks the first *valid* token in the iterator fn peek(&mut self) -> Option<&TokenWithContext> { self.skip_to_valid(); self.tokens....
{ // Peek to skip errors and keep track of them. // This makes unwrapping safe. self.skip_to_valid(); self.tokens.next().map(|r| r.unwrap()) }
identifier_body
compiler.rs
use frontend::scanner::{scan_into_iterator, Position, ScannerError, Token, TokenWithContext}; use num_traits::{FromPrimitive, ToPrimitive}; use std::iter::Peekable; use vm::bytecode::{BinaryOp, Chunk, Constant, OpCode}; #[derive(Debug)] pub enum ParsingError { /// The end of file has been reached but the parser ex...
{ ScannerError(ScannerError), ParsingError(ParsingError), } #[derive(PartialEq, PartialOrd, FromPrimitive, ToPrimitive, Clone, Copy)] enum Precedence { None, Assignment, Or, And, Equality, Comparison, Term, Factor, Unary, Call, Primary, } impl Precedence { /// ...
CompilationError
identifier_name
timeout_heap.rs
use futures::{Future, Poll, Async}; use std::cmp::{Ord, Ordering, PartialOrd}; use std::hash::Hash; use std::collections::{HashSet, BinaryHeap}; use std::time::Instant; use tokio::timer::Delay; pub struct TimeoutHeap<K> { deadlines: BinaryHeap<Deadline<K>>, key_set: HashSet<K>, delay: Delay, } impl<K> ...
// reverse order so that the maximum deadline expires first. other.instant.cmp(&self.instant) } } impl<K: Eq> PartialOrd for Deadline<K> { fn partial_cmp(&self, other: &Deadline<K>) -> Option<Ordering> { Some(self.cmp(other)) } }
random_line_split
timeout_heap.rs
use futures::{Future, Poll, Async}; use std::cmp::{Ord, Ordering, PartialOrd}; use std::hash::Hash; use std::collections::{HashSet, BinaryHeap}; use std::time::Instant; use tokio::timer::Delay; pub struct TimeoutHeap<K> { deadlines: BinaryHeap<Deadline<K>>, key_set: HashSet<K>, delay: Delay, } impl<K> ...
(&self, other: &Deadline<K>) -> Ordering { // reverse order so that the maximum deadline expires first. other.instant.cmp(&self.instant) } } impl<K: Eq> PartialOrd for Deadline<K> { fn partial_cmp(&self, other: &Deadline<K>) -> Option<Ordering> { Some(self.cmp(other)) } }
cmp
identifier_name
energy.rs
// Lumol, an extensible molecular simulation engine // Copyright (C) Lumol's contributors — BSD license use std::fs::File; use std::io::{self, BufWriter}; use std::io::prelude::*; use std::path::{Path, PathBuf}; use log::error; use super::Output; use lumol_core::System; use lumol_core::units; /// The `EnergyOutput`...
{ test_output( |path| Box::new(EnergyOutput::new(path).unwrap()), "# Energy of the simulation (kJ/mol) # Step Potential Kinetic Total 42 1.5000000000000027 949.9201593348566 951.4201593348566 ", ); } }
ergy()
identifier_name
energy.rs
// Copyright (C) Lumol's contributors — BSD license use std::fs::File; use std::io::{self, BufWriter}; use std::io::prelude::*; use std::path::{Path, PathBuf}; use log::error; use super::Output; use lumol_core::System; use lumol_core::units; /// The `EnergyOutput` writes the energy of the system to a text file, org...
// Lumol, an extensible molecular simulation engine
random_line_split
build.rs
extern crate pkg_config; use pkg_config::{Config, Error}; use std::env; use std::io::prelude::*; use std::io; use std::process; fn main() { if let Err(s) = find() { let _ = writeln!(io::stderr(), "{}", s); process::exit(1); } } fn find() -> Result<(), Error> { let package_name = "cairo"; ...
else { "1.10" }; if let Ok(lib_dir) = env::var("GTK_LIB_DIR") { for lib_ in shared_libs.iter() { println!("cargo:rustc-link-lib=dylib={}", lib_); } println!("cargo:rustc-link-search=native={}", lib_dir); return Ok(()) } let target = env::var("TARGET...
{ "1.12" }
conditional_block
build.rs
extern crate pkg_config; use pkg_config::{Config, Error}; use std::env; use std::io::prelude::*; use std::io; use std::process; fn main() { if let Err(s) = find() { let _ = writeln!(io::stderr(), "{}", s); process::exit(1); } } fn find() -> Result<(), Error> {
let shared_libs = ["cairo"]; let version = if cfg!(feature = "1.14") { "1.14" } else if cfg!(feature = "1.12") { "1.12" } else { "1.10" }; if let Ok(lib_dir) = env::var("GTK_LIB_DIR") { for lib_ in shared_libs.iter() { println!("cargo:rustc-link-lib=d...
let package_name = "cairo";
random_line_split
build.rs
extern crate pkg_config; use pkg_config::{Config, Error}; use std::env; use std::io::prelude::*; use std::io; use std::process; fn main() { if let Err(s) = find() { let _ = writeln!(io::stderr(), "{}", s); process::exit(1); } } fn find() -> Result<(), Error>
let hardcode_shared_libs = target.contains("windows"); let mut config = Config::new(); config.atleast_version(version); if hardcode_shared_libs { config.cargo_metadata(false); } match config.probe(package_name) { Ok(library) => { if hardcode_shared_libs { ...
{ let package_name = "cairo"; let shared_libs = ["cairo"]; let version = if cfg!(feature = "1.14") { "1.14" } else if cfg!(feature = "1.12") { "1.12" } else { "1.10" }; if let Ok(lib_dir) = env::var("GTK_LIB_DIR") { for lib_ in shared_libs.iter() { ...
identifier_body
build.rs
extern crate pkg_config; use pkg_config::{Config, Error}; use std::env; use std::io::prelude::*; use std::io; use std::process; fn main() { if let Err(s) = find() { let _ = writeln!(io::stderr(), "{}", s); process::exit(1); } } fn
() -> Result<(), Error> { let package_name = "cairo"; let shared_libs = ["cairo"]; let version = if cfg!(feature = "1.14") { "1.14" } else if cfg!(feature = "1.12") { "1.12" } else { "1.10" }; if let Ok(lib_dir) = env::var("GTK_LIB_DIR") { for lib_ in shared_...
find
identifier_name
prelude.rs
use cgmath; use glium; use std; pub use cgmath::EuclideanSpace; pub type Vector = cgmath::Vector3<f32>; pub type Point = cgmath::Point3<f32>; pub type Matrix = cgmath::Matrix3<f32>; mod dumb_submodule { use cgmath::{InnerSpace}; pub fn normalize(v: super::Vector) -> super::Vector { v.normalize() } pub ...
} pub use self::dumb_submodule::*; #[derive(Debug,Clone)] pub struct Ray { pub origin : Point, pub direction : Vector, } #[repr(C)] #[derive(Debug, Clone, Copy)] pub struct RGB { pub r: f32, pub g: f32, pub b: f32, } unsafe impl Send for RGB {} unsafe impl glium::texture::PixelValue for RGB { fn ge...
{ v1.cross(v2) }
identifier_body
prelude.rs
use cgmath; use glium; use std; pub use cgmath::EuclideanSpace; pub type Vector = cgmath::Vector3<f32>; pub type Point = cgmath::Point3<f32>; pub type Matrix = cgmath::Matrix3<f32>; mod dumb_submodule { use cgmath::{InnerSpace}; pub fn normalize(v: super::Vector) -> super::Vector { v.normalize() } pub ...
{ pub origin : Point, pub direction : Vector, } #[repr(C)] #[derive(Debug, Clone, Copy)] pub struct RGB { pub r: f32, pub g: f32, pub b: f32, } unsafe impl Send for RGB {} unsafe impl glium::texture::PixelValue for RGB { fn get_format() -> glium::texture::ClientFormat { glium::texture::ClientForm...
Ray
identifier_name
prelude.rs
use cgmath; use glium; use std; pub use cgmath::EuclideanSpace; pub type Vector = cgmath::Vector3<f32>;
pub type Matrix = cgmath::Matrix3<f32>; mod dumb_submodule { use cgmath::{InnerSpace}; pub fn normalize(v: super::Vector) -> super::Vector { v.normalize() } pub fn dot(v1: super::Vector, v2: super::Vector) -> f32 { v1.dot(v2) } pub fn cross(v1: super::Vector, v2: super::Vector) -> super::Vector ...
pub type Point = cgmath::Point3<f32>;
random_line_split
documenttype.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::DocumentTypeBinding; use dom::bindings::codegen::Bindings::DocumentTypeBindi...
} impl DocumentTypeMethods for DocumentType { // https://dom.spec.whatwg.org/#dom-documenttype-name fn Name(&self) -> DOMString { self.name.clone() } // https://dom.spec.whatwg.org/#dom-documenttype-publicid fn PublicId(&self) -> DOMString { self.public_id.clone() } // ht...
{ &self.system_id }
identifier_body
documenttype.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::DocumentTypeBinding; use dom::bindings::codegen::Bindings::DocumentTypeBindi...
(&self) { self.upcast::<Node>().remove_self(); } }
Remove
identifier_name
documenttype.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::DocumentTypeBinding; use dom::bindings::codegen::Bindings::DocumentTypeBindi...
let documenttype = DocumentType::new_inherited(name, public_id, system_id, document); Node::reflect_node(box documenttype, document, DocumentTypeBinding::Wrap) } #[inline] pub fn name(&self) -> &DOMString { &self.name } #[inline] pub fn public_id(&self) -> &DOMString { ...
document: &Document) -> Root<DocumentType> {
random_line_split
kindck-owned-trait-contains-1.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:Clone +'static>(v: Box<A>) -> Box<repeat<A>+'static> { box v as Box<repeat<A>+'static> // No } pub fn main() { let x = 3; let y = repeater(box x); assert_eq!(x, y.get()); }
repeater
identifier_name
kindck-owned-trait-contains-1.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!(x, y.get()); }
} pub fn main() { let x = 3; let y = repeater(box x);
random_line_split
kindck-owned-trait-contains-1.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 = 3; let y = repeater(box x); assert_eq!(x, y.get()); }
identifier_body
sgate.rs
/* * Copyright (C) 2018, Nils Asmussen <nils@os.inf.tu-dresden.de> * Economic rights: Technische Universitaet Dresden (Germany) * * This file is part of M3 (Microkernel-based SysteM for Heterogeneous Manycores). * * M3 is free software: you can redistribute it and/or modify * it under the terms of the GNU Genera...
} impl SendGate { pub fn new(rgate: &RecvGate) -> Result<Self, Error> { Self::new_with(SGateArgs::new(rgate)) } pub fn new_with(args: SGateArgs) -> Result<Self, Error> { let sel = if args.sel == INVALID_SEL { vpe::VPE::cur().alloc_sel() } else { arg...
{ self.sel = sel; self }
identifier_body
sgate.rs
/* * Copyright (C) 2018, Nils Asmussen <nils@os.inf.tu-dresden.de> * Economic rights: Technische Universitaet Dresden (Germany) * * This file is part of M3 (Microkernel-based SysteM for Heterogeneous Manycores). * * M3 is free software: you can redistribute it and/or modify * it under the terms of the GNU Genera...
} pub fn activate_for(&self, ep: Selector) -> Result<(), Error> { syscalls::activate(ep, self.sel(), 0) } #[inline(always)] pub fn send<T>(&self, msg: &[T], reply_gate: &RecvGate) -> Result<(), Error> { self.send_bytes(msg.as_ptr() as *const u8, msg.len() * util::size_of::<T>(), re...
random_line_split
sgate.rs
/* * Copyright (C) 2018, Nils Asmussen <nils@os.inf.tu-dresden.de> * Economic rights: Technische Universitaet Dresden (Germany) * * This file is part of M3 (Microkernel-based SysteM for Heterogeneous Manycores). * * M3 is free software: you can redistribute it and/or modify * it under the terms of the GNU Genera...
(mut self, credits: u64) -> Self { self.credits = credits; self } pub fn label(mut self, label: dtu::Label) -> Self { self.label = label; self } pub fn sel(mut self, sel: Selector) -> Self { self.sel = sel; self } } impl SendGate { pub fn new(rg...
credits
identifier_name
sgate.rs
/* * Copyright (C) 2018, Nils Asmussen <nils@os.inf.tu-dresden.de> * Economic rights: Technische Universitaet Dresden (Germany) * * This file is part of M3 (Microkernel-based SysteM for Heterogeneous Manycores). * * M3 is free software: you can redistribute it and/or modify * it under the terms of the GNU Genera...
else { args.sel }; syscalls::create_sgate(sel, args.rgate_sel, args.label, args.credits)?; Ok(SendGate { gate: Gate::new(sel, args.flags), }) } pub fn new_bind(sel: Selector) -> Self { SendGate { gate: Gate::new(sel, CapFlags...
{ vpe::VPE::cur().alloc_sel() }
conditional_block
util.rs
extern crate toml; use std::io::prelude::*; use std::fs::File; use std::path::Path; use toml::Value; pub fn slurp_config(path: &str) -> Value { let mut config_file = File::open(&Path::new(path)).unwrap(); let mut config_text = String::new(); let _ = config_file.read_to_string(&mut config_text); let ...
(usermask: &str) -> &str { let parts: Vec<&str> = usermask.split('!').collect(); let nick = parts[0]; if nick.starts_with(":") { return &nick[1..]; } else { return nick; } } #[cfg(test)] mod tests { use super::*; use toml; #[test] fn test_get_strings() { let...
nick_of
identifier_name
util.rs
extern crate toml; use std::io::prelude::*; use std::fs::File; use std::path::Path; use toml::Value;
let mut config_file = File::open(&Path::new(path)).unwrap(); let mut config_text = String::new(); let _ = config_file.read_to_string(&mut config_text); let mut parser = toml::Parser::new(&config_text[..]); match parser.parse() { Some(value) => return Value::Table(value), None => { ...
pub fn slurp_config(path: &str) -> Value {
random_line_split
util.rs
extern crate toml; use std::io::prelude::*; use std::fs::File; use std::path::Path; use toml::Value; pub fn slurp_config(path: &str) -> Value { let mut config_file = File::open(&Path::new(path)).unwrap(); let mut config_text = String::new(); let _ = config_file.read_to_string(&mut config_text); let ...
} #[cfg(test)] mod tests { use super::*; use toml; #[test] fn test_get_strings() { let mut parser = toml::Parser::new("[irc]\nautojoin = [\"#a\", \"#b\"]"); let config = parser.parse().map(|x| toml::Value::Table(x)).unwrap(); assert!(get_strings(&config, "irc.does_not_exist")....
{ return nick; }
conditional_block
util.rs
extern crate toml; use std::io::prelude::*; use std::fs::File; use std::path::Path; use toml::Value; pub fn slurp_config(path: &str) -> Value { let mut config_file = File::open(&Path::new(path)).unwrap(); let mut config_text = String::new(); let _ = config_file.read_to_string(&mut config_text); let ...
}
{ let mut parser = toml::Parser::new("[irc]\nautojoin = [\"#a\", \"#b\"]"); let config = parser.parse().map(|x| toml::Value::Table(x)).unwrap(); assert!(get_strings(&config, "irc.does_not_exist").is_empty()); assert_eq!(get_strings(&config, "irc.autojoin"), ["#a", "#b"]); }
identifier_body
box.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 ...
// debugger:run // debugger:finish // debugger:print *a // check:$1 = 1 // debugger:print *b // check:$2 = {2, 3.5} // debugger:print c->val // check:$3 = 4 // debugger:print d->val // check:$4 = false #[feature(managed_boxes)]; #[allow(unused_variable)]; fn main() { let a = ~1; let b = ~(2, 3.5); let c =...
// compile-flags:-Z extra-debug-info // debugger:set print pretty off // debugger:rbreak zzz
random_line_split
box.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 _zzz() {()}
{ let a = ~1; let b = ~(2, 3.5); let c = @4; let d = @false; _zzz(); }
identifier_body